ok
Direktori : /home2/selectio/public_html/frames-hub/ |
Current File : /home2/selectio/public_html/frames-hub/customer-edit.php |
<?php include 'header.php'; ?> <?php if(isset($_POST['customer_add_form'])) { $valid = 1; if($valid==1) { $statement = $pdo->prepare("UPDATE customer SET cust_firstname=?,cust_lastname=?,email=?,cust_phone=? WHERE id=?"); $result=$statement->execute(array($_POST['first_name'],$_POST['last_name'],$_POST['email'],$_POST['mobile'],$_POST['ids'])); $tot_count_frames = count($_POST['frames_id']); // Frame table update query starts here if($tot_count_frames>0){ for($s=0;$s<count($_POST['frames_id']);$s++) { $statement1 = $pdo->prepare("UPDATE `frames` SET `lens_type`='".$_POST['lens_type'][$s]."', `date`='".$_POST['lens_date'][$s]."',`fram_pd_first`='".$_POST['lens_pd'][$s]."',`frame_pd_second`='".$_POST['lens_pd_2'][$s]."',`right_sph`='".$_POST['right_cus_1'][$s]."',`right_cyl`='".$_POST['right_cus_2'][$s]."',`right_axis`='".$_POST['right_cus_3'][$s]."',`right_add`='".$_POST['right_cus_4'][$s]."',`left_sph`='".$_POST['left_cus_1'][$s]."',`left_cyl`='".$_POST['left_cus_2'][$s]."',`left_axis`='".$_POST['left_cus_3'][$s]."',`left_add`='".$_POST['left_cus_4'][$s]."' WHERE `id`='".$_POST['frames_id'][$s]."'"); $result1=$statement1->execute(); }} // Frames table update query ends here unset($_POST['first_name']); unset($_POST['last_name']); unset($_POST['email']); unset($_POST['mobile']); unset($_POST['ids']); echo ("<script LANGUAGE='JavaScript'> window.alert('Customer Updated Successfully'); </script>"); } } $statement = $pdo->prepare("SELECT * FROM customer where status=1 and id=".$_GET['id']); $result=$statement->execute(); $customer_data = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); if($totalData==1){ ?> <div class="page-wrapper"> <div class="page-content"> <div class="row"> <div class="col-md-12"> <?php if($error_message): ?> <div class="callout callout-danger"> <p> <?php echo $error_message; ?> </p> </div> <?php endif; ?> <?php if($success_message): ?> <div class="callout callout-success"> <p><?php echo $success_message; ?></p> </div> <?php endif; ?> </div> </div> <div class="row"> <form method="post" enctype="multipart/form-data"> <?php foreach($customer_data as $data){ ?> <div class="col-lg-12"> <div class="card" style="background-color: #a6c799;border-radius: 19px;box-shadow: 2px 2px 2px 2px currentColor;"> <div class="card-body"> <div class="row g-3"> <div class="col-12 col-lg-12"> <b style="font-weight: bolder;font-size: 17px;">Add Customer</b> <hr> </div> <div class="col-12 col-lg-3"> <label for="FisrtName" class="form-label required">Customer First Name</label> <input type="text" class="form-control" id="first_name" name="first_name" value="<?=$data['cust_firstname']?>" placeholder="FisrtName" required> <input type="hidden" class="form-control" id="ids" name="ids" value="<?=$_GET['id']?>" required> </div> <div class="col-12 col-lg-3"> <label for="Last Name" class="form-label required">Customer Last Name</label> <input type="text" class="form-control" id="last_name" name="last_name" value="<?=$data['cust_lastname']?>" placeholder="Last Name"> </div> <div class="col-12 col-lg-3"> <div class="mb-3"> <label class="form-label">Email</label> <input type="email" name="email" class="form-control" value="<?=$data['email']?>" placeholder="Email ID"> </div> </div> <div class="col-12 col-lg-3"> <div class="mb-3"> <label class="form-label required">Customer Phone</label> <input type="tel" name="mobile" class="form-control" placeholder="Mobile No" value="<?=$data['cust_phone']?>" required> </div> </div> </div> </div> </div> </div> <?php } ?> <?php $statement = $pdo->prepare("SELECT frames.*,customer.cust_firstname,customer.cust_phone FROM `frames` LEFT JOIN customer ON frames.customer_id=customer.id WHERE 1=1 and customer.id=".$customer_data[0]['id']); $statement->execute(); $customer_result = $statement->fetchAll(PDO::FETCH_ASSOC); $total_customer_frames=$statement->rowCount(); ?> <?php if($total_customer_frames>0){ ?> <div class="col-md-12 col-sm-12 col-xl-12"> <center><h2 style="font-family: SFProDisplay-Bold; font-size: 20px; margin-bottom: 2rem; font-weight">Update Power For Customer</h2></center> </div> <?php foreach($customer_result as $frames_result){ ?> <div class="row"> <div class="col=12 col-sm-12 col-md-12 col-xl-12"> <div class="card radius-10 border-start border-0 border-4"> <div class="card-body" style="background-color: #a6c799;border-radius: 12px;box-shadow: 2px 2px 2px 2px darkgrey;"> <br> <div class="col-12 col-md-12 col-lg-12"> <label for="FisrtName" class="form-label required" style="color:black;">Lens Type</label> <input type="text" class="form-control" id="lens_type" name="lens_type[]" value="<?=$frames_result['lens_type']?>" placeholder="Lens Type" required> <input type="hidden" class="form-control" id="frames_id" name="frames_id[]" value="<?=$frames_result['id']?>" placeholder="Lens Type" required> </div> <div class="row"> <div class="col-12 col-md-4 col-lg-4"> <div class="row"> <div class="col-12 col-md-12 col-lg-12"> <label for="FisrtName" class="form-label required" style="color:black;">Date</label> <input type="date" class="form-control" id="lens_date" name="lens_date[]" value="<?=$frames_result['date']?>" required> </div><br> <div class="col-12 col-md-12 col-lg-12"> <label for="FisrtName" class="form-label required" style="color:black;">PD</label> <div class="row"> <div class="col-6 col-sm-6 col-md-6 col-lg-6 col-xl-6"> <input type="text" class="form-control" id="lens_pd" name="lens_pd[]" value="<?=$frames_result['fram_pd_first']?>" required> </div> <div class="col-6 col-sm-6 col-md-6 col-lg-6 col-xl-6"> <input type="text" class="form-control" id="lens_pd_2" name="lens_pd_2[]" value="<?=$frames_result['frame_pd_second']?>" required> </div> </div> </div> </div> </div> <div class="col-12 col-md-8 col-lg-8"> <table style="width:100%;"> <tr style="background-color: burlywood;text-align: center;width:20%;"> <th style="padding:20px;width:2%;"></th> <th style="text-align:center;font-weight:bolder;width:22%;">SPH</th> <th style="text-align:center;font-weight:bolder;width:22%;">CYL</th> <th style="text-align:center;font-weight:bolder;width:22%;">AXIS</th> <th style="text-align:center;font-weight:bolder;width:22%;">ADD</th> </tr> <tr> <th style="background-color: burlywood;padding: 13px;">RE</th> <th><input type="number" name="right_cus_1[]" id="right_cus_1" step="0.25" class="form-control" style="width:100%;" value="<?=$frames_result['right_sph']?>"></th> <th><input type="number" name="right_cus_2[]" id="right_cus_2" step="0.25" class="form-control" style="width:100%;" value="<?=$frames_result['right_cyl']?>"></th> <th><input type="number" name="right_cus_3[]" id="right_cus_3" min="1" max="180" class="form-control" style="width:100%;" value="<?=$frames_result['right_axis']?>"></th> <th><input type="number" name="right_cus_4[]" id="right_cus_4" step="0.25" min="0.75" max="3" class="form-control" style="width:100%;" value="<?=$frames_result['right_add']?>"></th> </tr> <tr> <th style="background-color: burlywood;padding: 13px;">LE</th> <th><input type="number" name="left_cus_1[]" id="left_cus_1" step="0.25" class="form-control" style="width:100%;" value="<?=$frames_result['left_sph']?>"></th> <th><input type="number" name="left_cus_2[]" id="left_cus_2" step="0.25" class="form-control" style="width:100%;" value="<?=$frames_result['left_cyl']?>"></th> <th><input type="number" name="left_cus_3[]" id="left_cus_3" min="1" max="180" class="form-control" style="width:100%;" value="<?=$frames_result['left_axis']?>"></th> <th><input type="number" name="left_cus_4[]" id="left_cus_4" step="0.25" min="0.75" max="3" class="form-control" style="width:100%;" value="<?=$frames_result['left_add']?>"></th> </tr> </table> </div> </div> <!-- </div>--> </div> </div> </div> </div> <?php } } ?> <div class="col"> <center><button type="submit" class="btn btn-primary px-5" name="customer_add_form">Update Details</button></center> </div> </form> </div><br> <div class="row"> <div class="col-12"> <a href="customers.php"><center><button type="submit" class="btn btn-warning px-5">Customer List</button></center></a> </div> </div> </div> </div> <?php } include 'footer.php'; ?>