예제 #1
0
             array_push($sales_items, $sales_item);
         }
         $sale->setSalesItems($sales_items);
         $inserted_id = $sale->addSales();
         $message = "Sale completed successfuly";
         $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $inserted_id));
     } else {
         ob_start();
         $a = ob_get_clean();
         $responce = array('status' => 'failed', 'error' => 'Data missing' . $a, 'data' => array());
     }
 } else {
     if ($form_id == 4) {
         //bank deposit
         if (isset($_POST['amount']) and !empty($_POST['amount']) and isset($_POST['bank_id']) and !empty($_POST['bank_id']) and isset($_POST['description']) and !empty($_POST['description'])) {
             $bank_deposit = new bank_deposits();
             $bank_deposit->description = $_POST['description'];
             $bank_deposit->amount = $_POST['amount'];
             $bank_deposit->bank_id = $_POST['bank_id'];
             $user = new user();
             $user->id = $_SESSION['user_id'];
             $user->getUser();
             $bank_deposit->user_id = $user->id;
             $bank_deposit->company_id = $user->company_id;
             if ($bank_deposit->addBankDeposits()) {
                 $responce = array('status' => 'success', 'error' => '', 'data' => array('message' => 'Bank Deposit Added successfully'));
             } else {
                 Log::e($tag, "Bank Deposit adding failed, Bank Deposit : " . $bank_deposit->to_string() . 'Error : ' . mysql_error());
                 $mysql_error = mysql_error();
                 if (empty($mysql_error)) {
                     $error_message = 'Some server error occured';
                 $inv->in_stock_count = $inv->in_stock_count + $qty;
                 $inv->updateInventry();
                 $description = "Updating inventry (sales return - removed item) diff : " . $qty . ", inventry : " . $inv->to_string();
                 Log::i($tag, $description);
             }
         }
         $message = "Sale Updated Successfuly";
         $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $sale->id));
     } else {
         $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array());
     }
 } else {
     if ($form_id == 4) {
         // bank deposit edit
         if (isset($_POST['amount']) and !empty($_POST['amount']) and isset($_POST['bank_deposit_id']) and !empty($_POST['bank_deposit_id']) and isset($_POST['description']) and !empty($_POST['description'])) {
             $bank_deposit = new bank_deposits();
             $bank_deposit->id = $_POST['bank_deposit_id'];
             $bank_deposit->getBankDeposit();
             $bank_deposit->description = $_POST['description'];
             $bank_deposit->amount = $_POST['amount'];
             $bank_deposit->bank_id = $_POST['bank_id'];
             if ($bank_deposit->updateBankDeposit()) {
                 $responce = array('status' => 'success', 'error' => '', 'data' => array('message' => 'Bank Deposit Updated successfully'));
             } 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;
                 }
예제 #3
0
function get_form_html($form_id, $id, $page, $limit, $adjacents)
{
    ob_start();
    $bank_deposit = new bank_deposits();
    $user = new user();
    $user->id = $_SESSION['user_id'];
    $user->getUser();
    $count = $bank_deposit->getBankDepositsCount($user->company_id);
    if ($page == 1) {
        $start = 0;
        $head_message = "LAST {$limit} BANK DEPOSITS";
    } else {
        $start = ($page - 1) * $limit;
        $head_message = "BANK DEPOSITS {$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>
                            BANK
                        </td>
                        <td style="">
                            DESCRIPTION
                        </td>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $bank_deposits = $bank_deposit->getBankDeposits($user->company_id, $start, $limit);
    $i = $start;
    if ($bank_deposits == NULL || sizeof($bank_deposits) == 0) {
        echo '<tr><td colspan="8"> No Bank deposits Found </td></tr>';
    } else {
        foreach ($bank_deposits as $bank_deposit) {
            ?>
                        <tr id="<?php 
            echo $bank_deposit->id;
            ?>
"  onclick="select_row(this)" status="not_selected">
                            <td style="text-align: center;">
                                <?php 
            echo ++$i;
            ?>
                            </td>
                            <td>
                                <?php 
            echo $bank_deposit->id;
            ?>
                            </td>
                            <?php 
            $date = date('d/m/Y', strtotime($bank_deposit->deposited_at) + 5.5 * 60 * 60);
            $time = date('h:m a', strtotime($bank_deposit->deposited_at) + 5.5 * 60 * 60);
            ?>
                            <td>
                                <?php 
            echo $date . ' - ' . $time;
            ?>
                            </td>
                            <td id="amount"><?php 
            echo number_format($bank_deposit->amount, 2, '.', '');
            ?>
</td>
                            <?php 
            $bank = new bank();
            $bank->id = $bank_deposit->bank_id;
            $bank->getBank();
            ?>
                            <td id="bank" bank_id="<?php 
            echo $bank->id;
            ?>
">
                                <?php 
            echo $bank->bank_name . ' - ' . $bank->branch . ' - ' . $bank->account_number;
            ?>
                            </td>
                            <td id="description"><?php 
            echo $bank_deposit->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();
            var bank_id = selected_row.find('td#bank').attr('bank_id');
            get_form(4,  ///bank deposit 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('bank_deposit_id', id);
                    form.find('input#amount').val(amount);
                    form.find('textarea#description').val(description);
                    form.find('select#bank_account').val(bank_id);
                    form.find('input[type=submit]').val('UPDATE');
                    $('div#head_div').html('ID : BANK DEPOSIT-'+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 : 32,
                    bank_deposit_id : id
                }
                delete_form_data(data, function(message) {
                    get_form(32,
                        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(32,
                    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;
}
             $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 == 32) {
         ///bank deposit delete
         if (isset($_POST['bank_deposit_id']) and !empty($_POST['bank_deposit_id'])) {
             $bank_deposit = new bank_deposits();
             $bank_deposit->id = $_POST['bank_deposit_id'];
             if ($bank_deposit->deleteBankDeposit()) {
                 $message = "Bank Deposit deleted Successfuly";
                 $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $bank_deposit->id));
             } else {
                 $description = "Expence delete failed, Expence : " . $bank_deposit->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());
             }
예제 #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;
}