Exemplo n.º 1
0
             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 {
         ob_start();
         $a = ob_get_clean();
         $responce = array('status' => 'failed', 'error' => 'Data missing' . $a, 'data' => array());
     }
 } else {
     if ($form_id == 5) {
         if (isset($_POST['amount']) and !empty($_POST['amount']) and isset($_POST['description']) and !empty($_POST['description'])) {
             $expence = new expences();
             $expence->description = $_POST['description'];
             $expence->amount = $_POST['amount'];
             $user = new user();
             $user->id = $_SESSION['user_id'];
             $user->getUser();
             $expence->user_id = $user->id;
             $expence->company_id = $user->company_id;
             if ($expence->addExpence()) {
                 $responce = array('status' => 'success', 'error' => '', 'data' => array('message' => 'Expence Added successfully'));
             } else {
                 Log::e($tag, "Expence adding failed Expence : " . $expence->to_string() . 'Error : ' . mysql_error());
                 $mysql_error = mysql_error();
                 if (empty($mysql_error)) {
                     $error_message = 'Some server error occured';
                 } else {
             Log::e($tag, "Bank Deposit updation failed Expence : " . $bank_deposit->to_string() . 'Error : ' . mysql_error());
             $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 == 5) {
         if (isset($_POST['amount']) and !empty($_POST['amount']) and isset($_POST['expence_id']) and !empty($_POST['expence_id']) and isset($_POST['description']) and !empty($_POST['description'])) {
             $expence = new expences();
             $expence->id = $_POST['expence_id'];
             $expence->getExpence();
             $expence->description = $_POST['description'];
             $expence->amount = $_POST['amount'];
             if ($expence->updateExpence()) {
                 $responce = array('status' => 'success', 'error' => '', 'data' => array('message' => 'Expence Updated successfully'));
             } else {
                 Log::e($tag, "Expence updation failed Expence : " . $expence->to_string() . 'Error : ' . mysql_error());
                 $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());
             $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 == 31) {
         ///expence delete
         if (isset($_POST['expence_id']) and !empty($_POST['expence_id'])) {
             $expence = new expences();
             $expence->id = $_POST['expence_id'];
             if ($expence->deleteExpence()) {
                 $message = "Expence deleted Successfuly";
                 $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $expence->id));
             } else {
                 $description = "Expence delete failed, Expence : " . $expence->to_string() . " Error : " . mysql_error();
                 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());
             }
Exemplo n.º 4
0
function get_form_html($form_id, $id, $page, $limit, $adjacents)
{
    ob_start();
    $expence = new expences();
    $user = new user();
    $user->id = $_SESSION['user_id'];
    $user->getUser();
    $count = $expence->getExpencesCount($user->company_id);
    if ($page == 1) {
        $start = 0;
        $head_message = "LAST {$limit} EXPENCES";
    } else {
        $start = ($page - 1) * $limit;
        $head_message = "EXPENCES {$start} TO " . ($start + $limit);
    }
    ?>
    <div id="head_div" style="padding: 5px 0; background-color: #ECECEC;  color: #21ACD7;
         border-radius: 5px;margin-left: auto; text-align: center; ">
        <?php 
    echo $head_message;
    ?>
    </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 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  status="not_selected">
                        <td>
                            #
                        </td>
                        <td>
                            ID
                        </td>
                        <td>
                            DATE AND TIME
                        </td>
                        <td>
                            AMOUNT
                        </td>
                        <td style="">
                            DESCRIPTION
                        </td>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $expences = $expence->getExpences($user->company_id, $start, $limit);
    $i = $start;
    if ($expences == NULL || sizeof($expences) == 0) {
        echo '<tr><td colspan="8"> No Expence Found </td></tr>';
    } else {
        foreach ($expences as $expence) {
            ?>
                        <tr id="<?php 
            echo $expence->id;
            ?>
"  onclick="select_row(this)" status="not_selected">
                            <td style="text-align: center;">
                                <?php 
            echo ++$i;
            ?>
                            </td>
                            <td>
                                <?php 
            echo $expence->id;
            ?>
                            </td>
                            <?php 
            $date = date('d/m/Y', strtotime($expence->created_at) + 5.5 * 60 * 60);
            $time = date('h:m a', strtotime($expence->created_at) + 5.5 * 60 * 60);
            ?>
                            <td>
                                <?php 
            echo $date . ' - ' . $time;
            ?>
                            </td>
                            <td id="amount"><?php 
            echo number_format($expence->amount, 2, '.', '');
            ?>
</td>
                            <td id="description"><?php 
            echo $expence->description;
            ?>
</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 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 amount = selected_row.find('td#amount').html();
            var id = selected_row.attr('id');
            var description = selected_row.find('td#description').html();
            get_form(5,  ///expence 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('expence_id', id);
                    form.find('input#amount').val(amount);
                    form.find('textarea#description').val(description);
                    form.find('input[type=submit]').val('UPDATE');
                    $('div#head_div').html('ID : EXPENCE-'+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 EXPENCE-'+id+' ?' )){
                var data = {
                    form_id : 31,
                    expence_id : id
                }
                delete_form_data(data, function(message) {
                    get_form(31,
                        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(31,
                    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;
}
Exemplo n.º 5
0
function get_form_html($form_id, $date)
{
    ob_start();
    ?>
    <div id="head_div" style="padding: 5px 0; background-color: #ECECEC;  color: #21ACD7;
         border-radius: 5px;margin-left: auto; text-align: center; ">
        MONTHLY REPORT OF 
        <input id="year_field" value="<?php 
    if ($date == 0) {
        $year = date('Y', time());
    } else {
        $year = split('/', $date)[0];
    }
    echo $year;
    ?>
"  onchange="load_monthly_report()" style="width: 55px;" min="2015" max="2065" required />
        <select  id="month_field" onchange="load_monthly_report()" >
            <?php 
    if ($date == 0) {
        $month = date('m', time());
    } else {
        $month = split('/', $date)[1];
    }
    ?>
            <option <?php 
    if ($month == 1) {
        echo ' selected ';
    }
    ?>
 value="1">JANUARY</option>
            <option <?php 
    if ($month == 2) {
        echo ' selected ';
    }
    ?>
 value="2">FEBRUARY</option>
            <option <?php 
    if ($month == 3) {
        echo ' selected ';
    }
    ?>
 value="3">MARCH</option>
            <option <?php 
    if ($month == 4) {
        echo ' selected ';
    }
    ?>
 value="4">APRIL</option>
            <option <?php 
    if ($month == 5) {
        echo ' selected ';
    }
    ?>
 value="5">MAY</option>
            <option <?php 
    if ($month == 6) {
        echo ' selected ';
    }
    ?>
 value="6">JUNE</option>
            <option <?php 
    if ($month == 7) {
        echo ' selected ';
    }
    ?>
 value="7">JULY</option>
            <option <?php 
    if ($month == 8) {
        echo ' selected ';
    }
    ?>
 value="8">AUGUST</option>
            <option <?php 
    if ($month == 9) {
        echo ' selected ';
    }
    ?>
 value="9">SEPTEMBER</option>
            <option <?php 
    if ($month == 10) {
        echo ' selected ';
    }
    ?>
 value="10">OCTOBER</option>
            <option <?php 
    if ($month == 11) {
        echo ' selected ';
    }
    ?>
 value="11">NOVEMBER</option>
            <option <?php 
    if ($month == 12) {
        echo ' selected ';
    }
    ?>
 value="121">DECEMBER</option>
        </select>
    </div>
    <div id="content_table" 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="table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7;">
                <thead style="text-align: center;">
                    <tr>
                        <td style="width: 5%;">
                            #
                        </td>
                        <td>
                            DESCRIPTION
                        </td>
                        <td style="width: 15%;">
                            INCOME
                        </td>
                        <td style="width: 15%;">
                            EXPENCE
                        </td>
                        <td style="width: 15%;">
                            BALANCE
                        </td>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $balance = 0;
    $income_total = 0;
    $expence_total = 0;
    $user = new user();
    $user->id = $_SESSION['user_id'];
    $user->getUser();
    $i = 0;
    if ($year < 2015 || $year > 2065 || $month < 1 || $month > 12) {
        echo '<tr><td colspan="8"> In Valid Month Found </td></tr>';
    } else {
        //$grand_total = $grand_total + $sales_item->total;
        ?>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <?php 
        $sale = new sales();
        $vals = $sale->getOneMonthsSaleSummary($user->company_id, $month, $year);
        ?>
                            <td style="text-align: left;">
                                Sales
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['amount'], 2, '.', '');
        $income_total = $income_total + $vals['amount'];
        ?>
                            </td>
                            <td>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <td style="text-align: left;">
                                Tax
                            </td>
                            <td>
                                
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['tax_amount'], 2, '.', '');
        $expence_total = $expence_total + $vals['tax_amount'];
        ?>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <?php 
        $purchace = new purchaces();
        $vals = $purchace->getOneMonthsPurchaceSummary($user->company_id, $month, $year);
        ?>
                            <td style="text-align: left;">
                                Purchaces
                            </td>
                            <td>
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['amount'], 2, '.', '');
        $expence_total = $expence_total + $vals['amount'];
        ?>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <?php 
        $expence = new expences();
        $vals = $expence->getOneMonthsExpenceSummary($user->company_id, $month, $year);
        ?>
                            <td style="text-align: left;">
                                Expences
                            </td>
                            <td>
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['amount'], 2, '.', '');
        $expence_total = $expence_total + $vals['amount'];
        ?>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <?php 
        $bank_deposit = new bank_deposits();
        $vals = $bank_deposit->getOneMonthsBankDepositsSummary($user->company_id, $month, $year);
        ?>
                            <td style="text-align: left;">
                                Bank Deposit
                            </td>
                            <td>
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['amount'], 2, '.', '');
        $expence_total = $expence_total + $vals['amount'];
        ?>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <?php 
    }
    ?>
                        <tr>
                            <td></td>
                            <td style="text-align: right;"> TOTAL </td>
                            <td><?php 
    echo number_format($income_total, 2, '.', '');
    ?>
</td>
                            <td><?php 
    echo number_format($expence_total, 2, '.', '');
    ?>
</td>
                            <td><?php 
    echo number_format($balance, 2, '.', '');
    ?>
</td>
                        </tr>
                  </tbody>                               
            </table>
            <?php 
    /* ?>
       <table id="sales_statistics_table" style="border-collapse: collapse; width: 100%; 
              background-color: #fff; border-radius: 10px;  color: #21ACD7; margin-top: 20px;">
           <thead style="text-align: center;">
               <tr>
                       <td style="width: 5%;">
                           #
                       </td>
                       <td>
                           STATISTICS
                       </td>
                       <td style="width: 15%;">
                           COUNT
                       </td>
                       <td style="width: 15%;">
                           TOTAL TAX
                       </td>
                       <td style="width: 15%;">
                           TOTAL NET. AMOUNT
                       </td>
                       <td style="width: 15%;">
                           TOTAL AMOUNT
                       </td>
               </tr>
           </thead>
           <tbody style="text-align: center;">
               <tr style="margin-top: 20px;">
                   <?php
                   $sale = new sales();
                   $vals = $sale->getOneDaysSaleStatistics($user->company_id, $date);
                   ?>
                       <td>1</td>
                       <td style="text-align: left;">SALES</td>
                       <td><?php echo $vals['count']; ?></td>
                       <td><?php echo number_format($vals['tax_amount'], 2, '.',''); ?></td>
                       <td><?php echo number_format($vals['net_amount'], 2, '.',''); ?></td>
                       <td><?php echo number_format($vals['amount'], 2, '.',''); ?></td>
               </tr>
           </tbody>                               
       </table>
       <?php */
    ?>
        </div>
    </div>
    <script type="text/javascript">
        function load_monthly_report(){
            var year = $('input#year_field').val();
            if(year<2015 || year>2065){
                alert('Enter a valid year !');
                return; 
            }
            var month = $('select#month_field').val();
            get_form(33,
                        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);
                        },
                        year+'/'+month);
        }
        function on_print_clicked() {
            var year = $('input#year_field').val();
            var month = $('select#month_field option:selected').html();
            $('div#print_container_header')
                    .html('<font style="color:#21ACD7; font-size:20px; ">MONTHLY REPORT OF '+year+' '+month+'</font>');
            var html = $('div#content_table').html();
            $('div#print_container_body').html(html);  
            print();
            $('div#print_container_header').empty();
            $('div#print_container_body').empty();
            $('div#print_container_footer').empty();
        }
     </script>

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