require_once $file_name;
    } else {
        throw new Exception("Class " . $class_name . " Not found");
    }
});
session_start();
if (isset($_SESSION['user_id']) and !empty($_SESSION['user_id']) and isset($_GET['user_id']) and !empty($_GET['user_id']) and $_SESSION['user_id'] === $_GET['user_id']) {
    if (isset($_POST['form_id']) and !empty($_POST['form_id'])) {
        $form_id = $_POST['form_id'];
        $tag = "UPDATE_FORM_DATA";
        if ($form_id == 2) {
            ///sales return
            if (isset($_POST['total']) and isset($_POST['sale_id']) and !empty($_POST['sale_id']) and isset($_POST['net_amount']) and isset($_POST['tax_amount']) and isset($_POST['discount']) and isset($_POST['items']) and !empty($_POST['items'])) {
                $sale = new sales();
                $sale->id = $_POST['sale_id'];
                $sale->getSale();
                $balance = $_POST['total'] - $sale->amount;
                $sale->amount = $_POST['total'];
                $sale->net_amount = $_POST['net_amount'];
                $sale->tax_amount = $_POST['tax_amount'];
                $sale->discount = $_POST['discount'];
                $sales_items_prev = $sale->getSalesItems();
                $sales_items_new = array();
                if (!($_POST['items'] == 'no_items')) {
                    foreach ($_POST['items'] as $sales_array_item) {
                        $sales_item = new sales_items();
                        $sales_item->item_id = $sales_array_item['id'];
                        $sales_item->quantity = $sales_array_item['quantity'];
                        $sales_item->rate = $sales_array_item['rate'];
                        $sales_item->tax = $sales_array_item['tax'];
                        $sales_item->discount = $sales_array_item['discount'];
예제 #2
0
        require_once $file_name;
    } else {
        throw new Exception("Class " . $class_name . " Not found");
    }
});
session_start();
if (isset($_SESSION['user_id']) and !empty($_SESSION['user_id']) and isset($_GET['user_id']) and !empty($_GET['user_id']) and $_SESSION['user_id'] === $_GET['user_id']) {
    if (isset($_POST['form_id']) and !empty($_POST['form_id'])) {
        $form_id = $_POST['form_id'];
        $tag = "GET_FORM_DATA";
        if ($form_id == 2) {
            // sales
            if (isset($_POST['sale_id']) and !empty($_POST['sale_id'])) {
                $sale = new sales();
                $sale->id = $_POST['sale_id'];
                $result = $sale->getSale();
                if ($result) {
                    $user = new user();
                    $user->id = $_SESSION['user_id'];
                    $user->getUser();
                    if ($sale->company_id == $user->company_id) {
                        $message = "Sale Fetched successfuly";
                        $customer = new customer();
                        $customer->id = $sale->customer_id;
                        $customer->getCustomer();
                        $customer_name = $customer->customer_name . ' ( ' . $customer->id . ' ) ';
                        $items = array();
                        if (is_array($sale->getSalesItems()) and count($sale->getSalesItems())) {
                            foreach ($sale->getSalesItems() as $s_item) {
                                $item = new item();
                                $item->id = $s_item->item_id;