'SA_PURCHASEORDER' => array(SS_PURCH|3, _("Purchase order entry")),
'SA_GRN' => array(SS_PURCH|4, _("Purchase receive")),
'SA_SUPPLIERINVOICE' => array(SS_PURCH|5, _("Supplier invoices")),
- 'SA_GRNDELETE' => array(SS_PURCH|9, _("Deleting GRN items during invoice entry")),
'SA_SUPPLIERCREDIT' => array(SS_PURCH|6, _("Supplier credit notes")),
'SA_SUPPLIERPAYMNT' => array(SS_PURCH|7, _("Supplier payments")),
'SA_SUPPLIERALLOC' => array(SS_PURCH|8, _("Supplier payments allocations")),
return $myrow[0] > 0;
}
-function remove_not_invoice_item($id)
-{
- begin_transaction();
-
- $myrow = get_grn_item_detail($id);
-
- $grn = get_grn_batch($myrow['grn_batch_id']);
-
- $supp = get_supplier($grn["supplier_id"]);
-
- $sql = "UPDATE ".TB_PREF."purch_order_details
- SET quantity_received = qty_invoiced, quantity_ordered = qty_invoiced WHERE po_detail_item = ".$myrow["po_detail_item"];
- db_query($sql, "The quantity invoiced of the purchase order line could not be updated");
-
- $sql = "UPDATE ".TB_PREF."grn_items
- SET qty_recd = quantity_inv WHERE id = ".$myrow["id"];
- db_query($sql, "The quantity invoiced off the items received record could not be updated");
-
- update_average_material_cost($grn["supplier_id"], $myrow["item_code"],
- $myrow["unit_price"], -$myrow["QtyOstdg"], Today());
-
- $price = $myrow['unit_price'];
- if ($supp['tax_included'])
- $price = get_tax_free_price_for_item($myrow['item_code'], $myrow['unit_price'], $supp['tax_group_id'], $supp['tax_included']);
-
- add_stock_move(ST_SUPPRECEIVE, $myrow["item_code"], $myrow['grn_batch_id'], $grn['loc_code'], sql2date($grn["delivery_date"]), "",
- -$myrow["QtyOstdg"], $myrow['std_cost_unit'], $price);
-
- $clearing_act = get_company_pref('grn_clearing_act');
- if ($clearing_act) { // otherwise GRN clearing account is not used
- if (is_inventory_item($myrow['item_code']))
- {
- $total = 0;
- $stock_gl_code = get_stock_gl_code($myrow['item_code']);
- $date = sql2date($grn["delivery_date"]);
- $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $myrow['grn_batch_id'], $date, $stock_gl_code["inventory_account"],
- $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
- -$myrow['QtyOstdg'] * $price, $grn["supplier_id"], "", 0, _("GRN Removal"));
- $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $myrow['grn_batch_id'], $date, $clearing_act,
- 0, 0, -$total, null, "", 0, _("GRN Removal"));
- }
- }
-
- commit_transaction();
-}
-
function find_src_invoices($cart)
{
$invoices = $po_ids = array();
submit_cells('grn_item_id'.$n, _("Add"), '', _("Add to Invoice"), true);
else
submit_cells('grn_item_id'.$n, _("Add"), '', _("Add to Credit Note"), true);
- if (($supp_trans->trans_type == ST_SUPPINVOICE) && $_SESSION["wa_current_user"]->can_access('SA_GRNDELETE')) { // Added 2008-10-18 by Joe Hunt. Special access rights needed.
- submit_cells('void_item_id'.$n, _("Remove"), '', _("WARNING! Be careful with removal. The operation is executed immediately and cannot be undone !!!"), true);
- submit_js_confirm('void_item_id'.$n,
- sprintf(_('You are about to remove all yet non-invoiced items from delivery line #%d. This operation also irreversibly changes related order line. Do you want to continue ?'), $n));
- }
end_row();
}
}
if ($mode == 1)
{
if ($supp_trans->trans_type == ST_SUPPINVOICE)
- {
$heading = _("Items Received Yet to be Invoiced");
- if ($_SESSION["wa_current_user"]->can_access('SA_GRNDELETE')) // Added 2008-10-18 by Joe Hunt. Only admins can remove GRNs
- $heading2 = _("WARNING! Be careful with removal. The operation is executed immediately and cannot be undone !!!");
- }
else
$heading = _("Delivery Item Selected For Adding To A Supplier Credit Note");
}
_("Received On"), _("Quantity Received"), _("Quantity Invoiced"),
_("Qty Yet To Invoice"), $supp_trans->tax_included ? _("Price after Tax") : _("Price before Tax"),
_("Total"), "");
- if (($supp_trans->trans_type == ST_SUPPINVOICE) && $_SESSION["wa_current_user"]->can_access('SA_GRNDELETE')) // Added 2008-10-18 by Joe Hunt. Only admins can remove GRNs
- $th[] = "";
if ($supp_trans->trans_type == ST_SUPPCREDIT)
{
$th[7] = _("Qty Yet To Credit");
if ($mode == 1)
{
delete_button_cell("Delete" . $entered_grn->id, _("Edit"), _('Edit document line'));
- if (($supp_trans->trans_type == ST_SUPPINVOICE) && $_SESSION["wa_current_user"]->can_access('SA_GRNDELETE'))
- label_cell("");
}
end_row();
$Ajax->activate('gl_items');
}
-$id2 = -1;
-if ($_SESSION["wa_current_user"]->can_access('SA_GRNDELETE'))
-{
- $id2 = find_submit('void_item_id');
- if ($id2 != -1)
- {
- remove_not_invoice_item($id2);
- display_notification(sprintf(_('All yet non-invoiced items on delivery line # %d has been removed.'), $id2));
-
- }
-}
-
if (isset($_POST['go']))
{
$Ajax->activate('gl_items');
//-----------------------------------------------------------------------------------------
-if ($id != -1 || $id2 != -1)
+if ($id != -1)
{
$Ajax->activate('grn_items');
$Ajax->activate('inv_tot');