<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$this->load->helper('url');
$this->load->helper('form');
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title>All Customers</title>
        <link type="text/css" href="<?php echo base_url(); ?>/assests/css/style.min.css" rel="stylesheet" />
        <script type="text/javascript" src="<?php echo base_url(); ?>/assests/js/jquery-1.6.4.min.js"></script>
        <script type="text/javascript" src="<?php echo base_url(); ?>/assests/js/jquery.bpopup.min.js"></script>
        <script type="text/javascript" src="<?php echo base_url(); ?>/assests/js/jquery.easing.1.3.js"></script>
        <script type="text/javascript">
            function showUpdateCustomerPopUp(cus_id) {
                $('#psm_ac_customer_id').val(cus_id);
//                $('#psm_ac_customer_name').val(name);
//                $('#psm_ac_address').val(address);
//                $('#psm_ac_contact').val(contact);
//                $('#psm_ac_email').val(email);
//                $('#psm_ac_outstanding').val(outstanding);
//                $('#psm_ac_delete_status').val(delete_status);
//                if (delete_status == "0") {
//                    $('#delete_status_reset').show();
//                } else {
//                    $('#delete_status_reset').hide();
//                }
                $('#popup').bPopup({
                    easing: 'easeOutBack', //uses jQuery easing plugin
                    speed: 550,
                    transition: 'slideDown'
                });
            }
            function changeStatus() {
                $('#psm_ac_delete_status').val("1");
            }
        </script>
        <style type="text/css">
            #table_customer_details{
                border: solid 1px silver;
                border-collapse: collapse;
                margin-top: 20px;
                text-align: center;
            }
            #table_customer_details th{ 
                border: #000 solid 3px;
            }
        </style>
    </head>
    <body>
    <center>
        <table cellpadding="5" border="1" id="table_customer_details">
            <thead style="border: #000 solid 3px; background-color: #f1f1f1;">
                <tr>
                    <th>Customer ID</th>
                    <th>Customer Name</th>
                    <th>Address</th>
                    <th>Contact No</th>
                    <th>E-Mail</th>
                    <th>Outstanding</th>
                    <th>Status</th>
                    <th>Update</th>
                    <th>Delete</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach ($customers->result() as $cus) {
                    ?>
                    <tr>
                        <td><?php echo $cus->customer_id; ?></td>
                        <td><?php echo $cus->customer_name; ?></td>
                        <td><?php echo ""; ?></td>
                        <td><?php echo ""; ?></td>
                        <td><?php echo ""; ?></td>
                        <td><?php echo ""; ?></td>
                        <td><img title="Update Customer details" style="cursor: pointer;" width="40" src="<?php echo base_url(); ?>/assests/images/document_edit.png" onclick="showUpdateCustomerPopUp('<?php echo $cus->customer_id; ?>')" /></td>
                        <td><a href="<?php echo base_url(); ?>index.php/Customer_Controller/deleteCustomer?customer_id=<?php echo $cus->customer_id; ?>"><img title="Delete this Customer" style="cursor: pointer;" width="40" src="<?php echo base_url(); ?>/assests/images/document_delete.png"/></a></td>
                    </tr>
                    <?php
                }
                ?>
            </tbody>
        </table>
    </center>
</body>
<div id="popup" style="left: 541.5px; position: absolute; top: 1111px; z-index: 9999; opacity: 1; display: none;">
    <span class="button b-close"><span>X</span></span>
    <center>
        <?php
        echo form_open("Customer_Controller/updateCustomer");
        ?>
        <div style="font-weight: bolder;">Update Customer Details</div>
        <br>
        <table style="border-collapse:separate; border-spacing:5px 10px;" border="0">
            <tbody>
                <tr>
                    <td>Customer ID</td>
                    <td>:</td>
                    <td><input readonly="" id="psm_ac_customer_id" type="text" name="psm_ac_customer_id" value="" /></td>
                </tr>
                <tr>
                    <td>Customer Name</td>
                    <td>:</td>
                    <td><input type="text" name="add_cus_name" value="" /></td>
                </tr>
                <tr>
                    <td>Office Address</td>
                    <td>:</td>
                    <td><input type="text" name="add_cus_office_address" value="" /></td>
                </tr>
                <tr>
                    <td>Office Contact Number</td>
                    <td>:</td>
                    <td><input type="text" name="add_cus_office_contact" value="" /></td>
                </tr>
                <tr>
                    <td>Factory Address</td>
                    <td>:</td>
                    <td><input type="text" name="add_cus_factory_address" value="" /></td>
                </tr>
                <tr>
                    <td>Factory Contact Number</td>
                    <td>:</td>
                    <td><input type="text" name="add_cus_factoy_contact" value="" /></td>
                </tr>
                <tr>
                    <td>Contact Person 1</td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>Name</td>
                    <td>:</td>
                    <td><input type="text" name="cnp1_name" value="" /></td>
                </tr>
                <tr>
                    <td>Contact No</td>
                    <td>:</td>
                    <td><input type="text" name="cnp1_contact_no" value="" /></td>
                </tr>
                <tr>
                    <td>E-Mail</td>
                    <td>:</td>
                    <td><input type="text" name="cnp1_email" value="" /></td>
                </tr>
                <tr>
                    <td>Contact Person 2</td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>Name</td>
                    <td>:</td>
                    <td><input type="text" name="cnp2_name" value="" /></td>
                </tr>
                <tr>
                    <td>Contact No</td>
                    <td>:</td>
                    <td><input type="text" name="cnp2_contact_no" value="" /></td>
                </tr>
                <tr>
                    <td>E-Mail</td>
                    <td>:</td>
                    <td><input type="text" name="cnp2_email" value="" /></td>
                </tr>
                <tr>
                    <td>VAT Type</td>
                    <td>:</td>
                    <td>
                        <select name="vat_type">
                            <option>VAT</option>
                            <option>NON VAT</option>
                            <option>SVAT</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Current Outstanding</td>
                    <td>:</td>
                    <td><input type="text" name="current_outstanding" value="" /></td>
                </tr>
                <tr>
                    <td>Payment Type</td>
                    <td>:</td>
                    <td>
                        <select name="payment_type">
                            <option>Cash</option>
                            <option>Credit</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Credit Limit</td>
                    <td>:</td>
                    <td><input type="text" name="credit_limit" value="" /></td>
                </tr>
                <tr>
                    <td>Credit Period</td>
                    <td>:</td>
                    <td>
                        <select name="credit_period">
                            <option>30</option>
                            <option>45</option>
                            <option>90</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td><input type="submit" value="Submit" /></td>
                </tr>
            </tbody>
        </table>
        <?php
        echo form_close();
        ?>
    </center>
</div>
</html>
