예제 #1
0
             $purchace_item->quantity = $items_array_item['quantity'];
             $purchace_item->rate = $items_array_item['rate'];
             array_push($purchace_items, $purchace_item);
         }
         $purchace->setPurchaceItems($purchace_items);
         $purchace->addPurchace();
         $message = "Purchace added successfully";
         $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message));
     } else {
         $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array());
     }
 } else {
     if ($form_id == 10) {
         //vendor form
         if (isset($_POST['vendor_name']) and !empty($_POST['vendor_name']) and isset($_POST['contact_number']) and !empty($_POST['contact_number']) and isset($_POST['tin_number']) and !empty($_POST['tin_number']) and isset($_POST['contact_address']) and !empty($_POST['contact_address'])) {
             $vendor = new wendors();
             $vendor->wendor_name = $_POST['vendor_name'];
             $vendor->contact_no = $_POST['contact_number'];
             $vendor->wendor_tin_number = $_POST['tin_number'];
             $vendor->contact_address = $_POST['contact_address'];
             if ($vendor->addWendor()) {
                 $responce = array('status' => 'success', 'error' => '', 'data' => array('message' => 'Vendor Added successfully'));
             } else {
                 Log::e($tag, "Vendor adding failed item : " . $vendor->to_string());
                 $mysql_error = mysql_error();
                 if (empty($mysql_error)) {
                     $error_message = 'Some server error occured';
                 } else {
                     $error_message = $mysql_error;
                 }
                 $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array());
예제 #2
0
         $responce = array('status' => 'failed', 'error' => 'Data missing' . $a, 'data' => array());
     }
 } else {
     if ($form_id == 8) {
         //purchace
         if (isset($_POST['purchace_id']) and !empty($_POST['purchace_id'])) {
             $purchace = new purchaces();
             $purchace->id = $_POST['purchace_id'];
             $result = $purchace->getPurchace();
             if ($result) {
                 $user = new user();
                 $user->id = $_SESSION['user_id'];
                 $user->getUser();
                 if ($purchace->company_id == $user->company_id) {
                     $message = "Purchace Fetched successfuly";
                     $vendor = new wendors();
                     $vendor->id = $purchace->wendor_id;
                     $vendor->getWendor();
                     $vendor_name = $vendor->wendor_name . ' ( ' . $vendor->id . ' ) ';
                     $items = array();
                     if (is_array($purchace->getPurchaceItems()) and count($purchace->getPurchaceItems())) {
                         foreach ($purchace->getPurchaceItems() as $p_item) {
                             $item = new item();
                             $item->id = $p_item->item_id;
                             $item->getItem();
                             $p_item_array = array("item_name" => $item->item_name . ' - ' . $item->item_code . ' ( ID : ' . $item->id . ' )', "quantity" => number_format($p_item->quantity, 3, '.', ''), "rate" => number_format($p_item->rate, 2, '.', ''));
                             array_push($items, $p_item_array);
                         }
                     }
                     $purchace_array = array("id" => $purchace->id, "wendor" => $vendor_name, "stocked" => $purchace->stocked, "amount" => number_format($purchace->amount, 2, '.', ''), "bill_number" => $purchace->bill_number, "items" => $items);
                     $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "data" => $purchace_array));
             $mysql_error = mysql_error();
             if (empty($mysql_error)) {
                 $error_message = 'Some server error occured';
             } else {
                 $error_message = $mysql_error;
             }
             $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array());
         }
     } else {
         $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array());
     }
 } else {
     if ($form_id == 10) {
         ///edit vendor
         if (isset($_POST['vendor_id']) and !empty($_POST['vendor_id']) and isset($_POST['vendor_name']) and !empty($_POST['vendor_name']) and isset($_POST['contact_number']) and !empty($_POST['contact_number']) and isset($_POST['tin_number']) and !empty($_POST['tin_number']) and isset($_POST['contact_address']) and !empty($_POST['contact_address'])) {
             $vendor = new wendors();
             $vendor->id = $_POST['vendor_id'];
             $vendor->getWendor();
             $vendor->contact_address = $_POST['contact_address'];
             $vendor->contact_no = $_POST['contact_number'];
             $vendor->wendor_name = $_POST['vendor_name'];
             $vendor->wendor_tin_number = $_POST['tin_number'];
             if ($vendor->updateWendor()) {
                 $message = "Vendor Updated Successfuly";
                 $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $vendor->id));
             } else {
                 $description = "Vendor update failed, vendor : " . $vendor->to_string();
                 Log::e($tag, $description);
                 $mysql_error = mysql_error();
                 if (empty($mysql_error)) {
                     $error_message = 'Some server error occured';
             $mysql_error = mysql_error();
             if (empty($mysql_error)) {
                 $error_message = 'Some server error occured';
             } else {
                 $error_message = $mysql_error;
             }
             $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array());
         }
     } else {
         $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array());
     }
 } else {
     if ($form_id == 18) {
         ///vendor delete
         if (isset($_POST['vendor_id']) and !empty($_POST['vendor_id'])) {
             $vendor = new wendors();
             $vendor->id = $_POST['vendor_id'];
             if ($vendor->deleteWendor()) {
                 $message = "Vendor deleted Successfuly";
                 $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $vendor->id));
             } else {
                 $description = "Vendor delete failed, item : " . $vendor->to_string();
                 Log::e($tag, $description);
                 $mysql_error = mysql_error();
                 if (empty($mysql_error)) {
                     $error_message = 'Some server error occured';
                 } else {
                     $error_message = $mysql_error;
                 }
                 $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array());
             }
예제 #5
0
function get_form_html($form_id, $id)
{
    ob_start();
    ?>
    <div id="head_div" style="padding: 5px 0; background-color: #ECECEC;  color: #21ACD7;
         border-radius: 5px;margin-left: auto; text-align: center; ">
        UN-STOCKED PURCHACES
    </div>
    <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;">
        <style>
            div#purchace_items td{
                border: 1px solid #21ACD7;
            }
            div#purchace_items tbody td{
                padding: 5px 0 5px 5px;
            }
            div#purchace_items tbody td input,div#purchace_items tbody td select{
                padding: 0;
                border: 0;
                margin: 0;
                height: 100%;
                width: 100%;
                background-color: transparent;
            }
        </style>
        <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;">           
            <table id="items_table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7;">
                <thead style="text-align: center;">
                    <tr>
                        <td>
                            #
                        </td>
                        <td>
                            ID
                        </td>
                        <td>
                            DATE
                        </td>
                        <td style="">
                            PURCHACED FROM
                        </td>
                        <td style="">
                            PURCHACED BY
                        </td>
                        <td style="">
                            AMOUNT
                        </td>
                        <td style="">

                        </td>
                        <td style="">

                        </td>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $purchace_obj = new purchaces();
    $user = new user();
    $user->id = $_SESSION['user_id'];
    $user->getUser();
    $purchaces = $purchace_obj->getNotStockedPurchaces($user->company_id);
    $i = 0;
    if ($purchaces == NULL || sizeof($purchaces) == 0) {
        echo '<tr><td colspan="8"> No Purchace Found </td></tr>';
    } else {
        foreach ($purchaces as $purchace) {
            ?>
                        <tr id="<?php 
            echo $purchace->id;
            ?>
">
                            <td style="text-align: center;">
                                <?php 
            echo ++$i;
            ?>
                            </td>
                            <td>
                                <?php 
            echo $purchace->id;
            ?>
                            </td>
                            <td>
                                <?php 
            echo $purchace->created_at;
            ?>
                            </td>
                            <td>
                                <?php 
            $vendor = new wendors();
            $vendor->id = $purchace->wendor_id;
            $vendor->getWendor();
            echo $vendor->wendor_name;
            ?>
                            </td>
                            <td>
                                <?php 
            $p_manager = new user();
            $p_manager->id = $purchace->purchace_manager_id;
            $p_manager->getUser();
            echo $p_manager->name;
            ?>
                            </td>
                            <td>
                                <?php 
            echo $purchace->amount;
            ?>
                            </td>
                            <td id="ok_button" style="width: 20px;text-align: center; padding: 10px;">
                                <img id="add_to_stock_button" style="width: 20px; height: 20px; cursor: pointer;"
                                     onclick="add_to_stock(this)" src="../ui/images/tick_button.png"/>
                            </td>
                            <td id="down_button" style="width: 20px;text-align: center; padding: 10px;">
                                <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer;"
                                     onclick="toggle_items_visibility(this)" src="../ui/images/down_arrow.png"/>
                                <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer; display: none;"
                                     onclick="toggle_items_visibility(this)" src="../ui/images/up_arrow.png"/>
                            </td>
                        </tr>
                        <tr id="purchace_item" style="display: none;">
                            <td colspan="8" style="padding:0 0 20px 0;">
                                <table style="border-collapse: collapse; background-color: #c0effd; width: 80%; color: #21ACD7; float: right;">
                                    <tr>
                                        <td>
                                            ITEM
                                        </td>
                                        <td>
                                            QUANTITY
                                        </td>
                                        <td>
                                            PURCHACE RATE
                                        </td>
                                        <td>
                                            MRP
                                        </td>
                                        <td>
                                            TOTAL
                                        </td>
                                    </tr>
                                    <?php 
            foreach ($purchace->getPurchaceItems() as $p_item) {
                ?>
                                        <tr>
                                            <td>
                                                <?php 
                $item = new item();
                $item->id = $p_item->item_id;
                $item->getItem();
                echo $item->item_name . ' - ' . $item->item_code . ' (ID : ' . $item->id . ')';
                ?>
                                            </td>
                                            <td>
                                                <?php 
                echo $p_item->quantity;
                ?>
                                            </td>
                                            <td>
                                                <?php 
                echo $p_item->rate;
                ?>
                                            </td>
                                            <td>
                                                <?php 
                echo $item->mrp;
                ?>
                                            </td>
                                            <td>
                                        <?php 
                echo $p_item->quantity * $p_item->rate;
                ?>
                                            </td>
                                        </tr>
                                        <?php 
            }
            ?>
                                </table>
                            </td>
                        </tr>
                        <?php 
        }
    }
    ?>
                </tbody>                               
            </table>
        </div>
    </div>
    <script type="text/javascript">
        function add_to_stock(ok_button) {
            var row = $(ok_button).closest('tr');
            var purchace_id = row.attr('id');
            var data = {
                purchace_id: purchace_id
            }
            add_purchace_to_stock(data, function(message) {
                row.hide();
                row.next().hide();
                if(row.parent('tbody').children('tr:visible').length==0){
                    row.parent('tbody').html('<tr><td colspan="8"> No Purchace left more </td></tr>');
                }
                alert(message);
            }, function(message) {
                alert(message);
            });
        }
        function toggle_items_visibility(down_button) {
            var row = $(down_button).closest('tr');
            row.next('tr').fadeToggle();
            row.find('img#toggle_button').toggle();
            
        }
    </script>

    <?php 
    $form = ob_get_clean();
    return $form;
}
예제 #6
0
function get_form_html($form_id, $id, $page, $limit, $adjacents)
{
    ob_start();
    $purchace_obj = new purchaces();
    $user = new user();
    $user->id = $_SESSION['user_id'];
    $user->getUser();
    $count = $purchace_obj->getPurchacesCount($user->company_id);
    if ($page == 1) {
        $start = 0;
        $head_message = "LAST {$limit} PURCHACES";
    } else {
        $start = ($page - 1) * $limit;
        $head_message = "PURCHACE {$start} TO " . ($start + $limit);
    }
    ?>
    <div id="head_div" style="padding: 10px 0; background-color: #ECECEC;  color: #21ACD7;
         border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; ">
         <?php 
    echo $head_message;
    ?>
    </div>
    <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;">
        <style>
            div#purchace_items td, div#purchace_items th{
                border: 1px solid #21ACD7;
            }
            div#purchace_items tbody td{
                padding: 5px 0 5px 5px;
            }
            div#purchace_items tbody td input,div#purchace_items tbody td select{
                padding: 0;
                border: 0;
                margin: 0;
                height: 100%;
                width: 100%;
                background-color: transparent;
            }
        </style>
        <input type="text" id="search" placeholder="Enter Search Key here..." style="width: 100%; margin-left: 0px;" onkeyup="search()" />
        <style>
            img#search{
                position: relative;
                height: 20px;
                width: 20px;
                float: right;
                top: -29px;
                right: 10px;
            }
        </style>
        <img id="search" src="../ui/images/search.png" onclick="search()" />
        
        <div style="padding: 10px 0; background-color: transparent; 
             border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; ">
             <?php 
    echo pagination($limit, $adjacents, $count, $page);
    ?>
        </div>
        
        <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;">           
            <table id="items_table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7;">
                <thead style="text-align: center;">
                    <tr>
                        <th>
                            #
                        </th>
                        <th>
                            ID
                        </th>
                        <th>
                            BILL NO.
                        </th>
                        <th>
                            DATE
                        </th>
                        <th style="">
                            PURCHACED FROM
                        </th>
                        <th style="">
                            PURCHACED BY
                        </th>
                        <th>
                            AMOUNT
                        </th>
                        <th style="">
                            STOCKED
                        </th>
                        <th style="">

                        </th>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $purchaces = $purchace_obj->getPurchacesDESC($user->company_id, $start, $limit);
    $i = $start;
    if ($purchaces == NULL || sizeof($purchaces) == 0) {
        echo '<tr><td colspan="8"> No Purchace Found </td></tr>';
    } else {
        foreach ($purchaces as $purchace) {
            ?>
                            <tr id="<?php 
            echo $purchace->id;
            ?>
" onclick="select_row(this)" status="not_selected">
                                <td style="text-align: center;">
                                    <?php 
            echo ++$i;
            ?>
                                </td>
                                <td>
                                    <?php 
            echo $purchace->id;
            ?>
                                </td>
                                <td id="bill_number" >
                                    <?php 
            echo $purchace->bill_number;
            ?>
                                </td>
                                <?php 
            $date = date('d/m/Y', strtotime($purchace->created_at) + 5.5 * 60 * 60);
            $time = date('h:m A', strtotime($purchace->created_at) + 5.5 * 60 * 60);
            ?>
                                <td id="date" date="<?php 
            echo $date;
            ?>
">
                                    <?php 
            echo $date . ' - ' . $time;
            ?>
                                </td>
                                <?php 
            $vendor = new wendors();
            $vendor->id = $purchace->wendor_id;
            $vendor->getWendor();
            ?>
                                <td id="vendor" vendor_address="<?php 
            echo $vendor->contact_address;
            ?>
"><?php 
            echo $vendor->wendor_name;
            ?>
</td>
                                <td>
                                    <?php 
            $p_manager = new user();
            $p_manager->id = $purchace->purchace_manager_id;
            $p_manager->getUser();
            echo $p_manager->name;
            ?>
                                </td>
                                <td id="amount"><?php 
            echo $purchace->amount;
            ?>
</td>
                                <td>
                                    <?php 
            if ($purchace->stocked) {
                echo "YES";
            } else {
                echo 'NO';
            }
            ?>
                                </td>
                                <td id="down_button" style="width: 20px;text-align: center; padding: 10px;">
                                    <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer;"
                                         onclick="toggle_items_visibility(this)" src="../ui/images/down_arrow.png"/>
                                    <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer; display: none;"
                                         onclick="toggle_items_visibility(this)" src="../ui/images/up_arrow.png"/>
                                </td>
                            </tr>
                            <tr id="purchace_item" style="display: none;">
                                <td colspan="8" style="padding:0 0 20px 0;">
                                    <table id="purchace_items" style="border-collapse: collapse; background-color: #c0effd; width: 80%; color: #21ACD7; float: right;">
                                        <thead>
                                            <tr>
                                                <th>
                                                    ITEM
                                                </th>
                                                <th>
                                                    QUANTITY
                                                </th>
                                                <th>
                                                    PURCHACE RATE
                                                </th>
                                                <th>
                                                    MRP
                                                </th>
                                                <th>
                                                    TOTAL
                                                </th>
                                            </tr>
                                        </thead> 
                                        <tbody> 
                                            <?php 
            if (is_array($purchace->getPurchaceItems()) and count($purchace->getPurchaceItems()) > 0) {
                foreach ($purchace->getPurchaceItems() as $p_item) {
                    ?>
                                                <tr>
                                                    <td id="item_name"><?php 
                    $item = new item();
                    $item->id = $p_item->item_id;
                    $item->getItem();
                    echo $item->item_name . ' ( ' . $item->item_code . ' )';
                    ?>
</td>
                                                    <td id="quantity"><?php 
                    echo $p_item->quantity;
                    ?>
</td>
                                                    <?php 
                    $tax = new tax_category();
                    $tax->id = $item->tax_category_id;
                    $tax->getTaxCategory();
                    ?>
                                                    <td id="rate" tax_rate="<?php 
                    echo $tax->tax_percentage;
                    ?>
"><?php 
                    echo $p_item->rate;
                    ?>
</td>
                                                    <td><?php 
                    echo $item->mrp;
                    ?>
</td>
                                                    <td>
                                                        <?php 
                    echo $p_item->quantity * $p_item->rate;
                    ?>
                                                    </td>
                                                </tr>
                                                <?php 
                }
            } else {
                ?>
                                                <tr><td colspan="6">No Items found !</td></tr>    
                                                <?php 
            }
            ?>
                                        </tbody>        
                                    </table>
                                </td>
                            </tr>
                            <?php 
        }
    }
    ?>
                </tbody>                               
            </table>
        </div>
        <div style="padding: 10px 0; background-color: transparent; 
             border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; ">
             <?php 
    echo pagination($limit, $adjacents, $count, $page);
    ?>
        </div>
    </div>
    <script type="text/javascript">
        function toggle_items_visibility(down_button) {
            var row = $(down_button).closest('tr');
            row.next('tr').fadeToggle();
            row.find('img#toggle_button').toggle();

        }
        function select_row(row) {
            var j_row = $(row);
            if (j_row.attr('status') == 'selected') {
                $('table#items_table tr').attr('status', 'not_selected');
                $('table#items_table tr').css('background-color', '#FFF');
                $('img#print').css('display', 'none');
                $('img#print_fade').css('display', 'block');
                $('img#delete').css('display', 'none');
                $('img#delete_fade').css('display', 'block');
            } else {
                $('table#items_table tr').attr('status', 'not_selected');
                $('table#items_table tr').css('background-color', '#FFF');
                j_row.attr('status', 'selected');
                j_row.css('background-color', '#C0EFFD');
                $('img#print').css('display', 'block');
                $('img#print_fade').css('display', 'none');
                $('img#delete').css('display', 'block');
                $('img#delete_fade').css('display', 'none');
            }
        }

        function on_print_clicked() {
            var selected_row = $('tr[status="selected"]');
            var items_table_rows = selected_row.next('tr#purchace_item').find('table#purchace_items').find('tbody').children();
            var items = new Array();
            var i = 0;
            var tax_amount = 0;
            items_table_rows.each(function() {
                var item_row = $(this);
                var item_name = item_row.find('td#item_name').html();
                var quantity = item_row.find('td#quantity').html();
                var rate = item_row.find('td#rate').html();
                var tax_rate = item_row.find('td#rate').attr('tax_rate');
                var total = parseFloat(rate) * parseFloat(quantity);
                total = total.toFixed(2);
                var tax = (total * tax_rate) / (100);
                tax_amount = parseFloat(tax_amount) + parseFloat(tax);
                var item = {
                    item_name: item_name,
                    quantity: quantity,
                    rate: rate,
                    tax: tax,
                    tax_rate: tax_rate,
                    total: total
                }
                items[i++] = item;
            });
            tax_amount = tax_amount.toFixed(2);
            var vendor_name = selected_row.find('td#vendor').html();
            var vendor_address = selected_row.find('td#vendor').attr('vendor_address');
            var amount = selected_row.find('td#amount').html();
            amount = parseFloat(amount).toFixed(2);
            var id = selected_row.attr('id');
            var grand_total = (parseFloat(amount) + parseFloat(tax_amount));
            grand_total = grand_total.toFixed(2);
            var rounded_grand_total = Math.round(grand_total);
            rounded_grand_total = rounded_grand_total.toFixed(2);
            var round_off = grand_total - rounded_grand_total;
            round_off = round_off.toFixed(2);
            var bill_number = selected_row.find('td#bill_number').html();
            var date = selected_row.find('td#date').attr('date');
            var data = {
                id: id,
                vendor_name: vendor_name,
                vendor_address: vendor_address,
                amount: amount,
                date: date,
                less_discount: '0.00',
                tax_amount: tax_amount,
                grand_total: grand_total,
                rounded_grand_total: rounded_grand_total,
                round_off: round_off,
                bill_number: bill_number,
                items: items
            }
            print_purchace_invoice(data);
        }

        function print_purchace_invoice(data) {
            var html = '';
            html = '<font style="font-size:30px;">ROYALE PIKNIK TRADERS LLP</font><br/>'
                    + '<font>29/861, PARAYANCHERI, CALICUT - 673006</font><br/>'
                    + '<font>Tin No. 32110844692 </font><br/>'
                    + '<font>PURCHACE BILL</font><br/><br/>';
            $('div#print_container_header').html(html);
            html = '';
            //var d = new Date();
            //var date = d.getDate()+"/"+(parseInt(d.getMonth())+parseInt(1))+"/"+d.getFullYear();
            html = html + "<div<!-- style=\"padding:10px 0;\"><table style=\"float:right;\">"
                    + "<tr><td>Date</td><td>:</td><td>" + data.date + "</td></tr></table>";

            html = html + "<table>"
                    + "<tr><td>Bill No. </td><td>:</td><td>" + data.bill_number/*id*/ + "</td></tr>"
                    + "<tr><td>Name </td><td>:</td><td>" + data.vendor_name + "</td></tr>"
                    + "<tr><td></td><td>:</td><td>" + data.vendor_address + "</td></tr></table></div>";

            html = html + "<div style=\"border-top:1px dashed #000; margin:10px auto 0 auto;padding:0 0 10px 0;\"><table style=\"width:100%;\"><tr style=\"border-bottom: 1px dashed #000; border-top: 1px dashed #000;\">"
                    + "<td style=\"width:5%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px;\">SNo</td>"
                    + "<td style=\"width:30%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px;\">COMMODITY</td>"
                    + "<td style=\"width:20%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">SCH/HSN NO</td>"
                    + "<td style=\"width:10%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">RATE OF TAX</td>"
                    + "<td style=\"width:10%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">UNIT PRICE</td>"
                    + "<td style=\"width:10%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">QTY</td>"
                    + "<td style=\"width:15%; border-bottom:1px dashed #000; border-left:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:center;\">PURCHACE VALUE</td></tr>";
            var i = 1;
            for (var key in data.items) {
                var item = data.items[key];
                html = html + "<tr><td>" + i++ + "</td>"
                        + "<td colspan=\"2\">" + item.item_name + "</td>"
                        + "<td style=\"text-align:center;\">" + item.tax_rate + "</td>"
                        + "<td style=\"text-align:center;\">" + item.rate + "</td>"
                        + "<td style=\"text-align:center;\">" + item.quantity + "</td>"
                        //+"<td style=\"text-align:center;\">" + (parseFloat(item.total) - parseFloat(item.tax)) + "</td>"
                        //+"<td style=\"text-align:center;\">" + item.tax + "</td>"
                        + "<td style=\"text-align:right;\">" + item.total + "</td>"
                        + "</tr>";
            }
            html = html + "</table></div>";
            html = html + "<div style=\"border-top:1px dashed #000; padding:10px 0;\"><table style=\"margin-left: auto;\">";
            html = html + "<tr><td>Amount</td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\">" + data.amount + "</td></tr>";
            html = html + "<tr><td>Less Discount</td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\">" + data.less_discount + "</td></tr>";
            html = html + "<tr><td>VAT</td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\">" + data.tax_amount + "</td></tr>";
            html = html + "<tr><td>Round off</td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\">" + data.round_off + "</td></tr>";
            html = html + "<tr style=\"font-size:18px;\"><td><b>GRAND TOTAL</b></td><td style=\"margin:0 30px;\"></td><td style=\"text-align:right;\"><b>" + data.rounded_grand_total + "</b></td></tr>";
            html = html + "</table></div>";
    //                console.log("Creating bill : " + html);
            $('div#print_container_body').html(html);
            html = '';
            html = '<div style="width:100%;border-bottom:1px dashed #000;text-align:left;"><font>Rupees: ' + toWords(parseInt(data.rounded_grand_total)) + ' Only. </font></div>';
            $('div#print_container_footer').html(html);
            print();
            $('div#print_container_header').empty();
            $('div#print_container_body').empty();
            $('div#print_container_footer').empty();
        }
        // American Numbering System
        var th = ['', 'Thousand', 'Million', 'Billion', 'Trillion'];

        var dg = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'];

        var tn = ['Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'];

        var tw = ['Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'];

        function toWords(s) {
            s = s.toString();
            s = s.replace(/[\, ]/g, '');
            if (s != parseFloat(s))
                return 'not a number';
            var x = s.indexOf('.');
            if (x == -1)
                x = s.length;
            if (x > 15)
                return 'too big';
            var n = s.split('');
            var str = '';
            var sk = 0;
            for (var i = 0; i < x; i++) {
                if ((x - i) % 3 == 2) {
                    if (n[i] == '1') {
                        str += tn[Number(n[i + 1])] + ' ';
                        i++;
                        sk = 1;
                    } else if (n[i] != 0) {
                        str += tw[n[i] - 2] + ' ';
                        sk = 1;
                    }
                } else if (n[i] != 0) {
                    str += dg[n[i]] + ' ';
                    if ((x - i) % 3 == 0)
                        str += 'hundred ';
                    sk = 1;
                }
                if ((x - i) % 3 == 1) {
                    if (sk)
                        str += th[(x - i - 1) / 3] + ' ';
                    sk = 0;
                }
            }
            if (x != s.length) {
                var y = s.length;
                str += 'point ';
                for (var i = x + 1; i < y; i++)
                    str += dg[n[i]] + ' ';
            }
            return str.replace(/\s+/g, ' ');

        }

        function search() {
            var search_key = $('input#search').val();
            if (search_key !== '') {
                console.log("search key " + search_key);
                searchTable(search_key);
            } else {
                $('#items_table tr').show();
                $('#items_table tr#purchace_item').hide();
            }
        }

        function searchTable(inputVal) {
            var table = $('#items_table');
            table.find('tr').each(function(index, row)
            {
                if ($(row).attr('id') !== 'purchace_item') {
                    var allCells = $(row).find('td');
                    if (allCells.length > 0)
                    {
                        var found = false;
                        allCells.each(function(index, td)
                        {
                            var regExp = new RegExp(inputVal, 'i');
                            if (regExp.test($(td).text()))
                            {
                                found = true;
                                return false;
                            }
                        });
                        if (found == true)
                            $(row).show();
                        else
                            $(row).hide();
                    }

                    var items_row = $(row).next('tr');
                    var allCells = items_row.find('td');
                    if (allCells.length > 0)
                    {
                        var found = false;
                        allCells.each(function(index, td)
                        {
                            var regExp = new RegExp(inputVal, 'i');
                            if (regExp.test($(td).text()))
                            {
                                found = true;
                                return false;
                            }
                        });
                        if (found == true) {
                            $(row).show();
                            items_row.show();
                        } else {
                            items_row.hide();
                        }
                    }

                }
            });
        }

        function on_delete_clicked() {
            var selected_row = $('tr[status="selected"]');
            var id = selected_row.attr('id');
            if (confirm('Are you sure you want to delete PURCHACE-' + id + ' ?')) {
                var data = {
                    form_id: 19,
                    purchace_id: id
                }
                delete_form_data(data, function(message) {
                    get_form(19,
                            function(html, tools) {
                                $('div#form-body').html(html);
                                $('div#content-body-action-tools').html(tools);
                            }, function(message) {
                                $('font#section_heading').empty();
                                $('div#form-body').empty();
                                alert(message);
                    });
                    alert(message);
                }, function(message) {
                    alert(message);
                });
            }
        }
        
        function set_pagination_listener(){          
            $('.pagination').on('click','.page-numbers',function(e){
                e.preventDefault();
                var page = $(this).attr('page');
                var id = 0;
                get_form(19,
                    function(html, tools) {
                        $('div#form-body').html(html);
                        $('div#content-body-action-tools').html(tools);
                    }, function(message) {
                        $('font#section_heading').empty();
                        alert(message);
                    },id
                    ,page
                );
                return false;
             }); 
        }
        set_pagination_listener();
    </script>

    <?php 
    $form = ob_get_clean();
    return $form;
}
예제 #7
0
function get_form_html($form_id, $id)
{
    ob_start();
    ?>
    <div style="height: 150px; 
         width: 320px; background-color: #ECECEC; 
         border-radius: 5px;margin-left: auto;display: none; ">



    </div>
    <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;">
        <style>
            div#purchace_items td{
                border: 1px solid #21ACD7;
            }
            div#purchace_items tbody td{
                padding: 5px 0 5px 5px;
            }
            div#purchace_items tbody td input,div#purchace_items tbody td select{
                padding: 0;
                border: 0;
                margin: 0;
                height: 100%;
                width: 100%;
                background-color: transparent;
            }
        </style>
        <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;">           
            <table id="items_table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7;">
                <thead style="text-align: center;">
                    <tr status="not_selected">
                        <td>
                            #
                        </td>
                        <td>
                            ID
                        </td>
                        <td>
                            VENDOR NAME
                        </td>
                        <td>
                            CONTACT NUMBER
                        </td>
                        <td>
                            TIN NUMBER
                        </td>
                        <td style="">
                            CONTACT ADDRESS
                        </td>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $vendor = new wendors();
    $vendors = $vendor->getWendors();
    $i = 0;
    if ($vendors == NULL || sizeof($vendors) == 0) {
        echo '<tr><td colspan="8"> No Vendor Found </td></tr>';
    } else {
        foreach ($vendors as $vendor) {
            ?>
                    <tr id="<?php 
            echo $vendor->id;
            ?>
" onclick="select_row(this)"  status="not_selected">
                            <td style="text-align: center;"><?php 
            echo ++$i;
            ?>
</td>
                            <td><?php 
            echo 'VENDOR-' . $vendor->id;
            ?>
</td>
                            <td id="vendor_name"><?php 
            echo $vendor->wendor_name;
            ?>
</td>
                            <td id="contact_no"><?php 
            echo $vendor->contact_no;
            ?>
</td>
                            <td id="wendor_tin_number"><?php 
            echo $vendor->wendor_tin_number;
            ?>
</td>
                            <td id="contact_address"><?php 
            echo $vendor->contact_address;
            ?>
</td>
                        </tr>
                        <?php 
        }
    }
    ?>
                </tbody>                               
            </table>
        </div>
    </div>
    <script type="text/javascript">
        function select_row(row) {
            var j_row = $(row);
            if(j_row.attr('status') == 'selected'){
                $('table#items_table tr').attr('status', 'not_selected');
                $('table#items_table tr').css('background-color', '#FFF');
                $('img#edit').css('display', 'none');
                $('img#edit_fade').css('display', 'block');
                $('img#delete').css('display', 'none');
                $('img#delete_fade').css('display', 'block');
            }else{            
                $('table#items_table tr').attr('status', 'not_selected');
                $('table#items_table tr').css('background-color', '#FFF');
                j_row.attr('status', 'selected');
                j_row.css('background-color', '#C0EFFD');
                $('img#edit').css('display', 'block');
                $('img#edit_fade').css('display', 'none');
                $('img#delete').css('display', 'block');
                $('img#delete_fade').css('display', 'none');
            }          
        }
        function on_edit_clicked(){
            var selected_row = $('tr[status="selected"]');
            var vendor_name = selected_row.find('td#vendor_name').html();
            var id = selected_row.attr('id');
            var contact_number = selected_row.find('td#contact_no').html();
            var tin_number = selected_row.find('td#wendor_tin_number').html();
            var contact_address = selected_row.find('td#contact_address').html();
            get_form(10,  ///vendor create form
                function (html, tools){
                    $('div#form-body').html(html);
                    $('div#content-body-action-tools').html(tools);
                    var form = $('div#form-body').find('form.action_form');
                    form.attr('operation', 'update');
                    form.attr('vendor_id', id);
                    form.find('input#vendor_name').val(vendor_name);
                    form.find('input#contact_number').val(contact_number);
                    form.find('input#contact_address').val(contact_address);
                    form.find('input#tin_number').val(tin_number);
                    form.find('input[type=submit]').val('UPDATE');
                    $('div#head_div').html('ID : VENDOR-'+id);
                    $('div#head_div').css('display', 'block');
                },
                function (message){
                    $('font#section_heading').empty();
                    $('div#form-body').empty();
                    alert(message);
                }
             );
        }
        function on_delete_clicked(){            
            var selected_row = $('tr[status="selected"]');
            var id = selected_row.attr('id');
            if(confirm('Are you sure you want to delete VENDOR-'+id+' ?' )){
                var data = {
                    form_id : 18,
                    vendor_id : id
                }
                delete_form_data(data, function(message) {
                    get_form(18,
                        function(html, tools) {
                             $('div#form-body').html(html);
                             $('div#content-body-action-tools').html(tools);
                        }, function(message) {
                             $('font#section_heading').empty();
                             $('div#form-body').empty();
                             alert(message);
                        });
                    alert(message);
                }, function(message) {
                    alert(message);
                });
            }
        }
        
        function on_add_clicked(){
            get_form(10,  ///vendor create form
                function (html, tools){
                    $('div#form-body').html(html);
                    $('div#content-body-action-tools').html(tools);
                },
                function (message){
                    $('font#section_heading').empty();
                    $('div#form-body').empty();
                    alert(message);
                }
             );
        }
    </script>

    <?php 
    $form = ob_get_clean();
    return $form;
}
예제 #8
0
function get_form_html($form_id, $id)
{
    ob_start();
    ?>
    <style>
        .field_name{
            width: 20%;
        }
        .field{
            width: 50%;
        }
        .field input{
            width: 100%;
            margin-left: 0px;
        }
        .field .parent{
            padding: 0px 0px;
        }
        .field select{
            width: 100%;
        }
    </style>
    <div style="height: 150px; 
         width: 320px; background-color: #ECECEC; 
         border-radius: 5px;margin-left: auto;display: none; ">



    </div>
    <div style="margin-top: 10px; background-color:transparent;padding-bottom: 100px;">
        <form action="#" method="post" onsubmit="return false" class="action_form" operation="add" >
            <table style="width:100%;">
                <tr>
                    <td class="field_name">                    
                        <font>VENDOR</font>
                    </td>
                    <td class="field"> 
                        <div class="parent">
                            <input id="wendor_id" onfocus="$(this).css('border', '0px')" required list="wendors" autocomplete="off" style="border: 0;" />
                            <datalist id="wendors">
                                <?php 
    $wendor = new wendors();
    $wendors = array();
    $wendors = $wendor->getWendors();
    foreach ($wendors as $wendor) {
        echo '<option id="' . $wendor->id . '" value="' . $wendor->wendor_name . ' ( ID : ' . $wendor->id . ')" >' . $wendor->wendor_name . ' ( ID : ' . $wendor->id . ')' . '</option>';
    }
    ?>
    
                            </datalist>
                        </div>
                    </td>
                </tr>
                <?php 
    $purchace = new purchaces();
    $bill_number = $purchace->getMaxBillNumber() + 1;
    ?>
                <tr>
                    <td class="field_name"> 
                        <font>BILL NUMBER</font>
                    </td>
                    <td class="field"> 
                        <div class="parent">
                            <input type="text" id="bill_number" value="<?php 
    echo $bill_number;
    ?>
" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <style>
                            div#purchace_items td{
                                border: 1px solid #21ACD7;
                            }
                            div#purchace_items tbody td{
                                padding: 5px 0 5px 5px;
                            }
                            div#purchace_items tbody td input,div#purchace_items tbody td select{
                                padding: 0;
                                border: 0;
                                margin: 0;
                                height: 100%;
                                width: 100%;
                                background-color: transparent;
                            }
                        </style>
                        <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;">           
                            <table id="items_table" style="border-collapse: collapse; width: 100%; 
                                   background-color: #fff; border-radius: 10px;  color: #21ACD7;">
                                <thead style="text-align: center;">
                                    <tr>
                                        <td>
                                            #
                                        </td>
                                        <td>
                                            ITEM
                                        </td>
                                        <td style="width: 17%;">
                                            QUANTITY
                                        </td>
                                        <td style="width: 17%;">
                                            RATE
                                        </td>
                                        <td style="width: 17%;">
                                            TOTAL
                                        </td>
                                        <td style="width: 10%;">
                                            DELETE
                                        </td>
                                    </tr>
                                </thead>
                                <tbody style="padding-left: 3px;">
                                <datalist id="items">
                                    <?php 
    $item = new item();
    $items = array();
    $items = $item->getItems();
    foreach ($items as $item) {
        echo '<option id="' . $item->id . '"' . 'purchace_rate="' . $item->purchace_rate . '"' . ' value="' . $item->item_name . ' - ' . $item->item_code . '" >' . $item->item_name . ' - ' . $item->item_code . '</option>';
    }
    ?>
  
                                </datalist>
                                <?php 
    for ($i = 0; $i < 2; $i++) {
        ?>
                                    <tr  status="active" slno="<?php 
        echo $i + 1;
        ?>
">
                                        <td style="text-align: center;">
                                            <?php 
        echo $i + 1;
        ?>
                                        </td>
                                        <td>
                                            <input type="text" oninput="update_item_details(this)" onchange="update_item_details(this)" onfocus="$(this).css('border', '0px')" autocomplete="off" list="items" id="item" required />
                                        </td>
                                        <td>
                                            <input type="number" min="0" required onchange="calculate_total(this)" onkeyup="calculate_total(this)" step="0.001"  id="quantity"/>
                                        </td>
                                        <td>
                                            <input type="number" min="0" required onchange="calculate_total(this)" onkeyup="calculate_total(this)" step="0.01" id="rate"/>
                                        </td>
                                        <td>
                                            <input type="text" min="0" required  id="total" disabled/>
                                        </td>
                                        <td style="width: 20px; text-align: center; padding-right: 5px;">
                                            <img id="delete_button" onclick="delete_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto;  margin-left: auto;" src="../ui/images/cross_button.png"/>
                                            <img id="activate_button" onclick="enable_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto; margin-left: auto; display: none;" src="../ui/images/tick_button.png" />
                                        </td>
                                    </tr>
                                    <?php 
    }
    ?>
                                </tbody>                               
                            </table>
                        </div>
                    </td>
                </tr>
                <tr style="height: 5px;"></tr>
                <tr>
                    <td></td>
                    <td>
                        <div style="background-color: #21ACD7; color: #fff; text-align: center; padding-right: 20px;">
                            <span style="margin-right: 20px;">TOTAL </span>
                            <span id="total">0</span>
                        </div> 
                    </td>
                </tr>
                <tr style="height: 5px;"></tr>
                <tr>
                    <td></td>
                    <td>
                        <div style="padding: 0px 12px;">
                            <div style="width: 100%; margin-left: -12px; padding: 12px; 
                                 background-color: #0d92bb; border-radius: 5px; float: left;">

                                <div style="width: 33.33%; float: right;  ">
                                    <input style="width: 100%;" type="submit" value="ADD" />
                                </div>
                                <div style="width: 33.33%;  float: right;  ">
                                    <input style="width: 100%;" type="reset" value="CANCEL" /> 
                                </div>
                                <div style="width: 33.33%;">
                                    <input style="width: 100%;" onclick="add_purchace_item()" type="button" value="ADD ITEM" /> 
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <script type="text/javascript">
        function update_item_details(item) {
            var item_input = $(item);
            var item_name = item_input.val();
            var item_option_obj = $('datalist#items').find("option[value='" + item_name + "']");
            if (item_option_obj.length == "0") {
                return;
            } else {
                var purchace_rate = item_option_obj.attr('purchace_rate');
                var row = item_input.parent('td').parent('tr');
                row.find('input#rate').val(purchace_rate);
                calculate_total(row.find('input#rate').get(0));
            }
        }
        function calculate_total(field) {
            var $parent = $(field).closest('tr');
            var $quantity = parseFloat($parent.find('input#quantity').val());
            var $rate = parseFloat($parent.find('input#rate').val());
            var $total = $quantity * $rate;
            $total = parseFloat($total).toFixed(2);
            if ($.isNumeric($total)) {
                $parent.find('input#total').val($total);
            } else {
                $parent.find('input#total').val(0);
            }
            calculate_purchace_total();
        }
        function calculate_purchace_total() {
            var items_table = $('#items_table').find('tbody').children();
            var total = 0;
            items_table.each(function() {
                var item_total_input = $(this).find('input#total');
                var row_status = $(this).attr('status');
                var item_total = item_total_input.val();
                if ($.isNumeric(item_total) && row_status == 'active') {
                    total = parseFloat(total) + parseFloat(item_total);
                }
            });
            total = parseFloat(total).toFixed(2);
            $('span#total').html(total);
        }
        function delete_this_row(delete_btn) {
            var row = $(delete_btn).closest('tr');
            row.attr('status', 'deativated');
            row.css('background-color', '#c0effd');
            row.find('input').prop('required', null);
            row.find('input').css('border', "0px");
            $(delete_btn).css('display', 'none');
            $(delete_btn).siblings().first().css('display', 'block');
            $(delete_btn).parent('td').css('text-align', 'centre');
            calculate_purchace_total();
        }
        function enable_this_row(enable_btn) {
            var row = $(enable_btn).closest('tr');
            row.attr('status', 'active');
            row.css('background-color', '#fff');
            row.find('input').prop('required', 'required');
            $(enable_btn).siblings().first().css('display', 'block');
            $(enable_btn).css('display', 'none');
            $(enable_btn).parent('td').css('text-align', 'centre');
            calculate_purchace_total();
        }
        function add_purchace_item() {
            var row = '<tr  status="active" slno=""><td style="text-align: center;"></td><td>'
                    + '<input type="text" onchange="update_item_details(this)" oninput="update_item_details(this)" onfocus="$(this).css(\'border\', \'0px\')" autocomplete="off" list="items" id="item" required />'
                    + '</td><td><input type="number" min="0" required onchange="calculate_total(this)" onkeyup="calculate_total(this)" step="0.001" id="quantity"/>'
                    + '</td><td><input type="number" min="0" required onchange="calculate_total(this)" onkeyup="calculate_total(this)" step="0.01" id="rate"/>'
                    + '</td><td><input type="text" min="0" required  id="total" disabled/></td><td style="width: 20px; text-align: center; padding-right: 5px;">'
                    + '<img id="delete_button" onclick="delete_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto;  margin-left: auto;" src="../ui/images/cross_button.png"/>'
                    + '<img id="activate_button" onclick="enable_this_row(this)" style="color: #f00; cursor: pointer; height: 20px; width: 20px; margin-right: auto; margin-left: auto; display: none;" src="../ui/images/tick_button.png" />'
                    + '</td></tr>';
            var lastcount = $('table#items_table tbody tr:last-child').attr('slno');
            $('table#items_table tbody').append(row);
            lastcount = parseInt(lastcount) + 1;
            $('table#items_table tbody tr:last-child').attr('slno', lastcount);
            $('table#items_table tbody tr:last-child td:first-child').html(lastcount);
        }

        $(document).ready(function(e) {
            $('form.action_form').on('submit', function(e) {
                e.preventDefault();
                var wendor_input = $('form input#wendor_id');
                var wendor = wendor_input.val();
                var wendor_id = 0;
                var wendor_option_obj = $('datalist#wendors').find("option[value='" + wendor + "']");
                if (wendor_option_obj.length == "0") {
                    wendor_input.css('border', '1px solid #f00');
                    alert("Invalid Wendor");
                    return;
                } else {
                    wendor_id = wendor_option_obj.attr('id');
                }

                var items = new Array();
                var i = 0;
                var items_table = $('#items_table').find('tbody').children();
                var invalid_item_precent = false;
                items_table.each(function() {
                    if ($(this).attr('status') == 'active') {
                        var item_input = $(this).find('input#item');
                        var item_name = item_input.val();
                        var item_option_obj = $('datalist#items').find("option[value='" + item_name + "']");
                        if (item_option_obj.length == "0") {
                            item_input.css('border', '1px solid #f00');
                            invalid_item_precent = true;
                            return;
                        } else {
                            var id = item_option_obj.attr('id');
                            var quantity = $(this).find('input#quantity').val();
                            var rate = $(this).find('input#rate').val();
                            var item = {
                                id: id,
                                quantity: quantity,
                                rate: rate
                            }
                            items[i++] = item;
                        }
                    }
                });

                if (invalid_item_precent) {
                    //alert("Invalid Item Precent");
                    return;
                }

                var id = 7;
                var operation = $(this).attr('operation');
                var total = $('span#total').html();
                var bill_number = $('form input#bill_number').val();

                if (operation == 'add') {
                    var data = {
                        form_id: id,
                        wendor_id: wendor_id,
                        total: total,
                        bill_number: bill_number,
                        items: items
                    }
                    add_form_data(data, function(message) {
                        //$('form.action_form').get(0).reset();
                        get_form(7, function(html) {
                            $('div#form-body').html(html);
                        }, function(message) {
                            $('font#section_heading').empty();
                            $('div#form-body').empty();
                            alert(message);
                        });
                        alert(message);
                    }, function(message) {
                        alert(message);
                    });
                } else {
                    alert("Invalid Operation " + id + ' - ' + operation);
                }
            });
        });
    </script>

    <?php 
    $form = ob_get_clean();
    return $form;
}