Example #1
0
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This file is part of FBilling.
permissions.php - Responsible for permission management
*/
include "shared.php";
if ($action == 'edit' or $action == 'add') {
    // startif (action add/edit)
    if ($action == 'edit') {
        $permission_data = fbilling_get_data_by_id($cat, $id);
        // get weight ids belonging to this permission
        $permission_weights = fbilling_get_data_by_field('permission_weights', 'weight_id', 'permission_id', $permission_data['id']);
        // the ugly
        $selected_weights = array();
        foreach ($permission_weights as $p) {
            array_push($selected_weights, $p['0']);
        }
    }
    ?>
    <form name='permission_form' method='GET' onsubmit='return check_permission_form();'>
        <table>
            <tr>
                <td>
                    <a href='#' class='info'><?php 
    echo _("Permission Name");
    ?>
<span><?php 
Example #2
0
function fbilling_generate_invoice($src, $search_results, $search_summary)
{
    # filename related
    $extension_id = fbilling_get_data_by_field("extensions", "id", "sip_num", $src);
    $invoice_dir = "/var/www/html/fbilling_data/invoices/";
    $stamp = time();
    $creation_date = date("Y-m-d H:i:s");
    $invoice_file = "inv_" . $src . "_" . $stamp . ".pdf";
    $filename = $invoice_dir . $invoice_file;
    # pagind related
    $rows_per_page = 40;
    $rows = sizeof($search_results);
    $number_of_pages = ceil($rows / 40);
    # generate pdf
    $pdf = new PDF();
    $pdf->SetFont('Arial', '', 12);
    # WARNING, ugly things coming through!
    # for PDF pagination, we loop through number of pages we have
    for ($page = 0; $page < $number_of_pages; $page++) {
        $pdf->AddPage();
        # createnew page
        if ($page == 0) {
            # we need PDF header on first page
            $pdf->Cell(150, 10, "Invoice for extension {$src}", 0, 1, 'C');
        } else {
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Cell(150, 10, "Continued from page {$page}", 0, 1, 'C');
        }
        $pdf->Ln();
        # since we need pagination, we'd rather slice array then run several queries...
        $pdf->SetFont('Arial', '', 12);
        $page_rows = array_chunk($search_results, 38);
        $pdf->generate_table($page_rows[$page]);
        $pdf->SetFont('Arial', 'B', 8);
        $pdf->Ln();
        $pdf->Cell(150, 10, $page + 1, 0, 1, 'C');
    }
    # after pagination is done, create one last page with summary
    $pdf->AddPage();
    $pdf->SetFont('Arial', 'B', 12);
    $pdf->Cell(150, 10, "Summary for this invoice", 0, 1, 'C');
    # create summary table
    $pdf->Cell('90', 0, '', 'T');
    $pdf->Ln();
    #$pdf->Cell('90',0,'','T');
    $pdf->Cell('60', 6, "Number of Calls", 'LR');
    $pdf->Cell('30', 6, $search_summary['number_of_calls'], 'LR');
    $pdf->Ln();
    #$pdf->Cell('90',0,'','T');
    $pdf->Cell('60', 6, "Total Duration of Calls", 'LR');
    $pdf->Cell('30', 6, $search_summary['total_duration'], 'LR');
    $pdf->Ln();
    #$pdf->Cell('90',0,'','T');
    $pdf->Cell('60', 6, "Total Cost", 'LR');
    $pdf->Cell('30', 6, round($search_summary['total_cost'], 3), 'LR');
    $pdf->Ln();
    $pdf->Cell('90', 0, '', 'T');
    $pdf->Output($filename, 'F');
    // insert into invoice table
    $fields = array("extension_id", "creation_date", "filename");
    $values = array($extension_id[0][0], $creation_date, $invoice_file);
    fbilling_add("invoices", $fields, $values);
    return $invoice_file;
}