<?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 Materials</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 showUpdateMaterialsPopUp(mt_id, name, price) {
                $('#matr_id').val(mt_id);
                $('#material_name').val(name);
                $('#material_price').val(price);
                $('#popup').bPopup({
                    easing: 'easeOutBack', //uses jQuery easing plugin
                    speed: 550,
                    transition: 'slideDown'
                });
            }
        </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>Material ID</th>
                    <th>Material Name</th>
                    <th>Price</th>
                    <th>Update</th>
                    <th>Delete</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach ($matrls->result() as $mat) {
                    ?>
                    <tr>
                        <td><?php echo $mat->idprint_materials; ?></td>
                        <td><?php echo $mat->material_name; ?></td>
                        <td><?php echo $mat->material_price; ?></td>
                        <td><img title="Update Material details" style="cursor: pointer;" width="40" src="<?php echo base_url(); ?>/assests/images/document_edit.png" onclick="showUpdateMaterialsPopUp('<?php echo $mat->idprint_materials; ?>', '<?php echo $mat->material_name; ?>', '<?php echo $mat->material_price; ?>')" /></td>
                        <td><a href="<?php echo base_url(); ?>index.php/Material_Controller/deleteMaterial?mater_id=<?php echo $mat->idprint_materials; ?>"><img title="Delete this Material" 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("Material_Controller/updateMaterials");
        ?>
        <div style="font-weight: bolder;">Update Customer Details</div>
        <br>
        <table style="border-collapse:separate; border-spacing:5px 10px;" border="0">
            <tbody>
                <tr>
                    <td>Material ID</td>
                    <td>:</td>
                    <td><input readonly="" id="matr_id" type="text" name="matr_id" value="" /></td>
                </tr>
                <tr>
                    <td>Material Name</td>
                    <td>:</td>
                    <td><input id="material_name" type="text" name="material_name" value="" /></td>
                </tr>
                <tr>
                    <td>Price</td>
                    <td>:</td>
                    <td><input id="material_price" type="text" name="material_price" value="" /></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td><input type="submit" value="Submit" /></td>
                </tr>
            </tbody>
        </table>
        <?php
        echo form_close();
        ?>
    </center>
</div>
</html>
