public function insert_product_warehouse($form) { $data = array(); $data['product_id'] = $form['product_id']; $data['warehouse_cost'] = $form['product_cost']; $data['warehouse_price'] = $form['product_price']; $data['warehouse_quantity'] = $form['product_quantity']; $data['warehouse_barcode'] = $form['product_barcode']; $data['warehouse_qtytype'] = $form['p_qtytype']; $data['warehouse_sp_bill'] = $form['sup_bill']; $this->insert($this->table_name, $data); $accounts = new accounts(); $products = new product(); // Create GL $amount = $form['product_cost'] * $products->generate_item_quantity($form['product_id'], $form['p_qtytype'], $form['product_quantity']); $type = 'debit'; $account = 'Purchase'; $account_type = 'Stock'; $date = $accounts->_date('Y-m-d H:i:s', date('d-m-Y')); $results = $accounts->create_general_ledger($amount, $type, $account, $account_type, $date); // Purchase $product = $form['product_id']; $cost = $form['product_cost']; $quantity = $products->generate_item_quantity($form['product_id'], $form['p_qtytype'], $form['product_quantity']); $date = $date; $account = 'purchase'; $account_type = 'stock'; $results = $accounts->create_purchase($product, $cost, $quantity, $date, $account, $account_type); return $this->row_count(); }
} else { $type = 'debit'; } $bank_detail = $_POST['bank_detail']; if ($bank_detail) { $account = 'bank'; $account_type = $bank_detail; } else { $account = NULL; $account_type = NULL; } $date = new DateTime('now', new DateTimeZone('Asia/Karachi')); $date = $date->format("j-n-Y"); // Add General Ladger // $results = $accounts->create_general_ledger($amount, $type, $account, $account_type, $date); $results_general_ledger = $accounts->create_general_ledger($bill_amount, $type, $account, $account_type, $date); $account = 'supplier'; $account_type = $supplier_id; $type = 'payable'; $status = 0; // Add Account Payable //$results = $accounts->create_payable_receviable($amount, $account, $person, $date, $due_date, $type, $status); $results_account_payable = $accounts->create_payable_receviable($bill_amount, $account, $account_type, $date, $due_date, $type, $status); if (isset($results_account_payable)) { echo '<div class="alert alert-success" role="alert"> Add Purchase Sucessfully </div>'; } else { echo '<div class="alert alert-danger" role="alert"> Error </div>'; } } ?>