include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
+include_once($path_to_root . "/reporting/includes/reporting.inc");
$js = "";
if ($SysPrefs->use_popup_windows)
$js .= get_js_open_window(800, 500);
"/dimensions/dimension_entry.php?trans_no=" . $row["id"], ICON_EDIT);
}
+function prt_link($row)
+{
+ return print_document_link($row['id'], _("Print"), true, ST_DIMENSION, ICON_PRINT);
+}
+
+
$sql = get_sql_for_search_dimensions($dim, $_POST['FromDate'], $_POST['ToDate'],
$_POST['OrderNumber'], $_POST['type_'], check_value('OpenOnly'), check_value('OverdueOnly'));
_("Due Date") => array('name'=>'due_date', 'type'=>'date', 'ord'=>'asc'),
_("Closed") => array('fun'=>'is_closed'),
_("Balance") => array('type'=>'amount', 'insert'=>true, 'fun'=>'sum_dimension'),
- array('insert'=>true, 'fun'=>'edit_link')
+ array('insert'=>true, 'fun'=>'edit_link'),
+ array('insert'=>true, 'fun'=>'prt_link')
);
if ($outstanding_only) {
}
function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $alsoclosed=false,
- $user_id=null, $contractor_id=null, $dimension=null)
+ $user_id=null)
{
-
- $sql = "SELECT IFNULL(a.gl_seq,0) as gl_seq,
- gl.tran_date,
- gl.type as trans_type,
- gl.type_no as trans_no,
- IFNULL(MAX(supp.supp_name), MAX(cust.name)) as name,
- IF(ISNULL(st.supp_reference), '', st.supp_reference) AS supp_reference,
- refs.reference,"
- .($dimension ? " -SUM(IF(dim.dimension in(gl.dimension_id,gl.dimension2_id), gl.amount, 0)) as amount,":" SUM(IF(gl.amount>0, gl.amount,0)) as amount,")
- ."com.memo_,
- IF(ISNULL(u.user_id),'',u.user_id) as user_id";
-
- if ($contractor_id > 0) {
- $sql.= ", st.supplier_id, dt.debtor_no ";
- }
-
- $sql.= " FROM ".TB_PREF."gl_trans as gl
- LEFT JOIN ".TB_PREF."audit_trail as a ON
- (gl.type=a.type AND gl.type_no=a.trans_no)
- LEFT JOIN ".TB_PREF."comments as com ON
- (gl.type=com.type AND gl.type_no=com.id)
- LEFT JOIN ".TB_PREF."refs as refs ON
- (gl.type=refs.type AND gl.type_no=refs.id)
- LEFT JOIN ".TB_PREF."users as u ON
- a.user=u.id
- LEFT JOIN ".TB_PREF."debtor_trans dt ON dt.type=gl.type AND gl.type_no=dt.trans_no
- LEFT JOIN ".TB_PREF."debtors_master cust ON gl.person_type_id=2 AND gl.person_id=cust.debtor_no
- LEFT JOIN ".TB_PREF."supp_trans st ON st.type=gl.type AND gl.type_no=st.trans_no
- LEFT JOIN ".TB_PREF."suppliers supp ON gl.person_type_id=3 AND gl.person_id=supp.supplier_id"
- .($dimension ?
- " LEFT JOIN (SELECT type, type_no, MAX(IFNULL(dimension_id, dimension2_id)) dimension FROM ".TB_PREF."gl_trans GROUP BY type, type_no) dim
- ON gl.type=dim.type AND gl.type_no=dim.type_no" : '')
- ." WHERE gl.tran_date >= '" . date2sql($from) . "'
- AND gl.tran_date <= '" . date2sql($to) . "'
- AND gl.amount!=0";
- if ($ref) {
- $sql .= " AND refs.reference LIKE ". db_escape("%$ref%");
- }
- if ($memo) {
- $sql .= " AND com.memo_ LIKE ". db_escape("%$memo%");
- }
- if ($filter != -1) {
- $sql .= " AND gl.type=".db_escape($filter);
- }
- if (!$alsoclosed) {
- $sql .= " AND gl_seq=0";
- }
- else
- $sql .= " AND NOT ISNULL(a.gl_seq)";
-
- if ($user_id != null)
- $sql .= " AND user_id = ".db_escape($user_id);
-
- if ($contractor_id > 0) {
- $sql.= " AND (dt.debtor_no =".$contractor_id;
- $sql.= " OR st.supplier_id =".$contractor_id.") ";
- }
-
- if ($dimension != null)
- $sql .= " AND dim.dimension = ".db_escape($dimension);
-
- $sql .= " GROUP BY gl.tran_date, a.gl_seq, gl.type, gl.type_no";
-
- return $sql;
+ $sql = "SELECT IFNULL(a.gl_seq,0) as gl_seq,
+ gl.tran_date,
+ gl.type as trans_type,
+ gl.type_no as trans_no,
+ IFNULL(gl.person_id, IFNULL(st.supplier_id, IFNULL(grn.supplier_id, IFNULL(dt.debtor_no, bt.person_id)))) as person_id,
+ IF(ISNULL(st.supp_reference), '', st.supp_reference) AS supp_reference,
+ refs.reference,
+ IF(gl.type=".ST_BANKTRANSFER.",MAX(gl.amount),SUM(IF(gl.amount>0, gl.amount,0))) as amount,
+ com.memo_,
+ IF(ISNULL(u.user_id),'',u.user_id) as user_id,
+ IF(gl.person_id, gl.person_type_id, IF(!ISNULL(st.supplier_id) OR !ISNULL(grn.supplier_id),". PT_SUPPLIER . "," . "IF(dt.debtor_no," . PT_CUSTOMER . "," .
+ "IF(bt.person_id != '' AND !ISNULL(bt.person_id), bt.person_type_id, -1)))) as person_type_id
+ FROM ".TB_PREF."gl_trans as gl
+ LEFT JOIN ".TB_PREF."audit_trail as a ON
+ (gl.type=a.type AND gl.type_no=a.trans_no)
+ LEFT JOIN ".TB_PREF."comments as com ON
+ (gl.type=com.type AND gl.type_no=com.id)
+ LEFT JOIN ".TB_PREF."refs as refs ON
+ (gl.type=refs.type AND gl.type_no=refs.id)
+ LEFT JOIN ".TB_PREF."users as u ON
+ a.user=u.id
+ LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=gl.type_no AND gl.type=".ST_SUPPRECEIVE."
+ LEFT JOIN ".TB_PREF."bank_trans bt ON bt.type=gl.type AND bt.trans_no=gl.type_no AND bt.amount!=0
+ AND (bt.person_id != '' AND !ISNULL(bt.person_id))
+ LEFT JOIN ".TB_PREF."debtor_trans dt ON dt.type=gl.type AND gl.type_no=dt.trans_no
+ LEFT JOIN ".TB_PREF."supp_trans st ON st.type=gl.type AND gl.type_no=st.trans_no
+ WHERE gl.tran_date >= '" . date2sql($from) . "'
+ AND gl.tran_date <= '" . date2sql($to) . "'
+ AND gl.amount!=0";
+ if ($ref) {
+ $sql .= " AND refs.reference LIKE ". db_escape("%$ref%");
+ }
+ if ($memo) {
+ $sql .= " AND com.memo_ LIKE ". db_escape("%$memo%");
+ }
+ if ($filter != -1) {
+ $sql .= " AND gl.type=".db_escape($filter);
+ }
+ if (!$alsoclosed) {
+ $sql .= " AND gl_seq=0";
+ }
+ else
+ $sql .= " AND NOT ISNULL(a.gl_seq)";
+
+ if ($user_id != null)
+ $sql .= " AND user_id = ".db_escape($user_id);
+
+ $sql .= " GROUP BY gl.tran_date, a.gl_seq, gl.type, gl.type_no";
+ return $sql;
}
$event_date='', $doc_date='')
{
$sql = "INSERT INTO ".TB_PREF."journal(
- `type`,`trans_no`, `amount`, `currency`, `rate`, `reference`, `source_ref`, `tran_date`,
- `event_date`, `doc_date`)
- VALUES("
+ `type`,`trans_no`, `amount`, `currency`, `rate`, `reference`, `source_ref`, `tran_date`,`event_date`,`doc_date`)
+ VALUES("
.db_escape($type).","
.db_escape($trans_no).","
.db_escape($amount).","
.db_escape($rate).","
.db_escape($reference).","
.db_escape($source_ref).","
- ."'".date2sql($tran_date)."',"
- ."'".date2sql($event_date)."',"
- ."'".date2sql($doc_date)."')";
+ ."'".date2sql($tran_date)."','"
+ . ($event_date === '' ? '0000-00-00' : date2sql($event_date))."','"
+ . ($doc_date === '' ? '0000-00-00' : date2sql($doc_date))."')";
return db_query($sql, 'cannot add journal entry');
}
."`rate`=".db_escape($rate).","
."`reference`=".db_escape($reference).","
."`source_ref`=".db_escape($source_ref).","
- ."`tran_date`="."'".date2sql($tran_date)."',"
- ."`event_date`="."'".date2sql($event_date)."',"
- ."`doc_date`="."'".date2sql($doc_date)."'
+ ."`tran_date`='".date2sql($tran_date)."',"
+ ."`event_date`='".($event_date === '' ? '0000-00-00' : date2sql($event_date))."',"
+ ."`doc_date`='".($doc_date === '' ? '0000-00-00' : date2sql($doc_date))."'
WHERE `type`=".db_escape($type)." AND " ."`trans_no`=".db_escape($trans_no);
return db_query($sql, 'cannot update journal entry');
ref_cells(_("Reference:"), 'Ref', '',null, _('Enter reference fragment or leave empty'));
journal_types_list_cells(_("Type:"), "filterType");
-date_cells(_("From:"), 'FromDate', '', null, 0, -1, 0);
+date_cells(_("From:"), 'FromDate', '', null, -user_transaction_days());
date_cells(_("To:"), 'ToDate');
end_row();
return $systypes_array[$type];
}
+function person_link($row)
+{
+ return payment_person_name($row["person_type_id"],$row["person_id"]);
+}
+
function view_link($row)
{
return get_trans_view_str($row["trans_type"], $row["trans_no"]);
_("Date") =>array('name'=>'tran_date','type'=>'date','ord'=>'desc'),
_("Type") => array('fun'=>'systype_name'),
_("Trans #") => array('fun'=>'view_link'),
- _("Counterparty") => array('ord' => ''),
+ _("Counterparty") => array('fun' => 'person_link'),
_("Supplier's Reference") => 'skip',
_("Reference"),
_("Amount") => array('type'=>'amount'),
function add_audit_trail($trans_type, $trans_no, $trans_date, $descr='')
{
+ $descr = substr($descr, 0, 60);
begin_transaction();
$date = date2sql($trans_date);
// to avoid need for subqueries (not existing in MySQL 3) all over the code
$sql = "UPDATE ".TB_PREF."audit_trail audit LEFT JOIN ".TB_PREF."fiscal_year year ON year.begin<='$date' AND year.end>='$date'
SET audit.gl_seq = IF(audit.id=".db_insert_id().", 0, NULL),"
- ."audit.fiscal_year=year.id, stamp=CURRENT_TIMESTAMP"
+ ."audit.fiscal_year=year.id"
. " WHERE type=".db_escape($trans_type)." AND trans_no="
. db_escape($trans_no);
$selector .= ' '.$opts['editlink'];
if ($search_box && $opts['cells'])
- $str = ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector$img</td>";
+ $str = ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td nowrap>$selector$img</td>";
else
$str = $edit_entry.$selector.$img;
return $str;
if ($label != null)
echo "<td>$label</td>\n";
echo sales_items_list($name, $selected_id, $all_option, $submit_on_change,
- '', array('cells'=>true));
+ '', array('cells'=>true, 'max'=>50)); // maximum is set to 50 and not default 255.
}
function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
// When there is no exrate for today,
// gets it form ECB and stores in local database.
//
-function exchange_rate_display($from_currency, $to_currency, $date_, $force_edit=false)
+function exchange_rate_display($from_currency=null, $to_currency=null, $date_, $force_edit=false)
{
global $Ajax, $SysPrefs;
$rate = input_num('_ex_rate');
if (check_ui_refresh() || !$rate) { // readonly or ui context changed
$comp_currency = get_company_currency();
+
+ if (!isset($from_currency))
+ $from_currency = $comp_currency;
+ if (!isset($to_currency))
+ $to_currency = $comp_currency;
+
if ($from_currency == $comp_currency)
$currency = $to_currency;
else
if ($id != -1)
handle_delete_item($id);
-if (isset($_POST['AddItem']) && check_item_data())
+if (isset($_POST['AddItem']) && check_item_data()) {
handle_new_item();
-
-if (isset($_POST['UpdateItem']) && check_item_data())
+ unset($_POST['selected_id']);
+}
+if (isset($_POST['UpdateItem']) && check_item_data()) {
handle_update_item();
-
+ unset($_POST['selected_id']);
+}
if (isset($_POST['CancelItemChanges'])) {
+ unset($_POST['selected_id']);
line_start_focus();
}
//-----------------------------------------------------------------------------------------------
foreach ($items as $line_item)
{
- if ($SysPrefs->loc_notification() == 1 && $line_item->qty < 0)
+ if ($SysPrefs->loc_notification() == 1 && $line_item->quantity < 0)
{
- $chg = $line; $chg->qty = -$chg->qty; // calculate_reorder_level expect positive qty
- $loc = calculate_reorder_level($location, $line_item, $st_ids, $st_names, $st_num, $st_reorder);
+ $chg = $line_item; $chg->quantity= -$chg->quantity; // calculate_reorder_level expect positive qty
+ $loc = calculate_reorder_level($location, $chg, $st_ids, $st_names, $st_num, $st_reorder);
}
add_stock_adjustment_item($adj_id, $line_item->stock_id, $location, $date_, $reference,
{
$before_date = date2sql($BeforeDate);
$after_date = date2sql($AfterDate);
- $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.name, supplier.supp_name) name";
+ // PO Delivery and Customer Credit Notes references should be saved in stock moves reference in 2.5
+ $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.name, supplier.supp_name) name,
+ IF(move.type=".ST_SUPPRECEIVE.", grn.reference, IF(move.type=".ST_CUSTCREDIT.", cust_trans.reference, move.reference)) reference";
if(!$StockLocation) {
$sql .= ", move.loc_code";
}
$sql.= " FROM ".TB_PREF."stock_moves move
LEFT JOIN ".TB_PREF."supp_trans credit ON credit.trans_no=move.trans_no AND credit.type=move.type
- LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=move.trans_no AND 25=move.type
+ LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=move.trans_no AND move.type=".ST_SUPPRECEIVE."
LEFT JOIN ".TB_PREF."suppliers supplier ON IFNULL(grn.supplier_id, credit.supplier_id)=supplier.supplier_id
LEFT JOIN ".TB_PREF."debtor_trans cust_trans ON cust_trans.trans_no=move.trans_no AND cust_trans.type=move.type
LEFT JOIN ".TB_PREF."debtors_master debtor ON cust_trans.debtor_no=debtor.debtor_no
_("Unit"), _("Unit Cost"), _("Total"), "");
if ( count($order->line_items)) $th[] = '';
}
- if ( count($order->line_items)) $th[] = '';
table_header($th);
$total = 0;
$k = 0; //row colour counter
$low_stock = $order->check_qoh($_POST['StockLocation'], $_POST['AdjDate']);
- $id = find_submit('Edit');
+ $id = get_post('selected_id', find_submit('Edit'));
foreach ($order->line_items as $line_no=>$stock_item)
{
amount_cell($stock_item->standard_cost * $stock_item->quantity);
if (!$order->fixed_asset) {
- edit_button_cell("Edit$line_no", _("Edit"), _('Edit document line'));
+ if ($id == -1)
+ edit_button_cell("Edit$line_no", _("Edit"), _('Edit document line'));
+ else
+ label_cell('');
}
- delete_button_cell("Delete$line_no", _("Delete"), _('Remove line from document'));
+ if ($id == -1)
+ delete_button_cell("Delete$line_no", _("Delete"), _('Remove line from document'));
+ else
+ label_cell('');
+
end_row();
}
else
label_row(_("Total"), number_format2($total,user_price_dec()), "align=right colspan=5", "align=right", 2);
end_table();
+
+ if ($id != -1)
+ hidden('selected_id', $id);
if ($low_stock)
display_note(_("Marked items have insufficient quantities in stock as on day of adjustment."), 0, 1, "class='stockmankofg'");
div_end();
start_row();
$dec2 = 0;
- $id = find_submit('Edit');
- if ($line_no != -1 && $line_no == $id)
- {
- $_POST['stock_id'] = $order->line_items[$id]->stock_id;
- $_POST['qty'] = qty_format($order->line_items[$id]->quantity,
- $order->line_items[$id]->stock_id, $dec);
- //$_POST['std_cost'] = price_format($order->line_items[$id]->standard_cost);
- $_POST['std_cost'] = price_decimal_format($order->line_items[$id]->standard_cost, $dec2);
- $_POST['units'] = $order->line_items[$id]->units;
+ if ($line_no != -1)
+ {
+ if (find_submit('Edit') != -1) {
+ $_POST['stock_id'] = $order->line_items[$line_no]->stock_id;
+ $_POST['qty'] = qty_format($order->line_items[$line_no]->quantity,
+ $order->line_items[$line_no]->stock_id, $dec);
+ //$_POST['std_cost'] = price_format($order->line_items[$line_no]->standard_cost);
+ $_POST['std_cost'] = price_decimal_format($order->line_items[$line_no]->standard_cost, $dec2);
+ }
+ $_POST['units'] = $order->line_items[$line_no]->units;
hidden('stock_id', $_POST['stock_id']);
label_cell($_POST['stock_id']);
- label_cell($order->line_items[$id]->item_description, 'nowrap');
+ label_cell($order->line_items[$line_no]->item_description, 'nowrap');
$Ajax->activate('items_table');
}
else
stock_costable_items_list_cells(null, 'stock_id', null, false, true);
if (list_updated('stock_id')) {
- $Ajax->activate('units');
- $Ajax->activate('qty');
- $Ajax->activate('std_cost');
- $Ajax->activate('std_cost_view');
- $Ajax->activate('initial_price');
+ $Ajax->activate('items_table');
}
- $item_info = get_item_edit_info($_POST['stock_id']);
+ }
+
+ $item_info = get_item_edit_info(get_post('stock_id'));
+ if ($item_info) {
$dec = $item_info['decimals'];
- $_POST['qty'] = number_format2(0, $dec);
$_POST['std_cost'] = price_decimal_format($item_info["material_cost"], $dec2);
$_POST['units'] = $item_info["units"];
- }
-
+ } else
+ $dec = 0;
if ($order->fixed_asset) {
hidden('qty', -1);
qty_cell(1, false, 0);
} else
- qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
+ label_cell( text_input('qty', get_post('qty', '0'), 15, 15, '', 'class="amount active" dec='.$dec), "nowrap align=right");
- label_cell($_POST['units'], '', 'units');
+ label_cell(get_post('units'), '', 'units');
if ($order->fixed_asset) {
- /* TODO: check if this is a correct way of creating a fixed item
- that still has to be submitted in the form */
hidden('std_cost');
label_cell($_POST['std_cost'], "nowrap align=right ", 'std_cost_view');
$price = get_purchase_value($_POST['stock_id']);
amount_cell($price, false, '', 'initial_price');
} else {
- //amount_cells(null, 'std_cost', $_POST['std_cost']);
- amount_cells(null, 'std_cost', null, null, null, $dec2);
+ if (get_post('_qty_changed')) {
+ $Ajax->activate('items_table');
+ set_focus(input_num('qty') >= 0 ? 'std_cost' : 'AddItem');
+ }
+ if (input_num('qty') >= 0)
+ amount_cells(null, 'std_cost', null, null, null, $dec);
+ else {
+ hidden('std_cost');
+ label_cell($_POST['std_cost'], "nowrap align=right");
+ }
label_cell(" ");
}
- if ($id != -1)
+ if ($line_no != -1)
{
button_cell('UpdateItem', _("Update"),
_('Confirm changes'), ICON_UPDATE);
button_cell('CancelItemChanges', _("Cancel"),
_('Cancel changes'), ICON_CANCEL);
hidden('LineNo', $line_no);
- set_focus('qty');
+ set_focus('qty');
}
else
{
return false;
}
},
- '.amount': function(e) {
- if(e.onblur==undefined) {
+ '.amount': function(e) {
+ if (e.onblur == undefined) {
+ e.setAttribute('_last_val', e.value);
e.onblur = function() {
var dec = this.getAttribute("dec");
- price_format(this.name, get_amount(this.name), dec);
+ var val = this.getAttribute('_last_val');
+ if (val != get_amount(this.name)) {
+ this.setAttribute('_last_val', get_amount(this.name));
+ price_format(this.name, get_amount(this.name), dec);
+ if (e.className.match(/\bactive\b/))
+ JsHttpRequest.request('_'+this.name+'_changed', this.form);
+ }
};
}
},
table_header($th);
$k = 0;
+ $found = false;
while ($myrow = db_fetch($result))
{
-
+ $found = true;
alt_table_row_color($k);
label_cell($myrow["component"]);
} //END WHILE LIST LOOP
end_table();
+
+ if ($found) {
+ start_table(TABLESTYLE, "width='60%'");
+ stock_manufactured_items_list_row(_("Copy BOM to another manufacturable item"), 'new_stock_id', $selected_parent, false, true);
+ end_table();
+ }
+
div_end();
}
+function copy_bom_items($stock_id, $new_stock_id)
+{
+ $result = get_bom($stock_id);
+ while ($myrow = db_fetch($result))
+ {
+ $_POST['component'] = $myrow["component"];
+ $_POST['loc_code'] = $myrow["loc_code"];
+ $_POST['workcentre_added'] = $myrow["workcentre_added"];
+ $_POST['quantity'] = $myrow["quantity"];
+ on_submit($new_stock_id, -1);
+ }
+}
+
//--------------------------------------------------------------------------------------------------
function on_submit($selected_parent, $selected_component=-1)
//--------------------------------------------------------------------------------------------------
+if (list_updated('new_stock_id')) {
+ copy_bom_items($_POST['stock_id'], $_POST['new_stock_id']);
+ $item = get_item($_POST['new_stock_id']);
+ $_POST['stock_id'] = $_POST['new_stock_id'];
+ $Ajax->activate('_page_body');
+ display_notification(_("BOM copied to ") . $item['description']);
+}
+
start_form();
start_form(false, true);
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc");
+include_once($path_to_root . "/reporting/includes/reporting.inc");
+
$js = "";
if ($SysPrefs->use_popup_windows)
$js .= get_js_open_window(800, 500);
return get_gl_view_str(ST_WORKORDER, $row['id']);
}
+function prt_link($row)
+{
+ return print_document_link($row['id'], _("Print"), true, ST_WORKORDER, ICON_PRINT);
+}
+
function dec_amount($row, $amount)
{
return number_format2($amount, $row['decimals']);
_("Manufactured") => array('fun'=>'dec_amount', 'align'=>'right'),
_("Date") => array('name'=>'date_', 'type'=>'date', 'ord'=>'desc'),
_("Required By") => array('type'=>'date', 'ord'=>''),
+ array('insert'=>true, 'fun'=> 'view_gl_link'),
array('insert'=>true, 'fun'=> 'edit_link'),
array('insert'=>true, 'fun'=> 'release_link'),
array('insert'=>true, 'fun'=> 'costs_link'),
array('insert'=>true, 'fun'=> 'produce_link'),
- array('insert'=>true, 'fun'=> 'view_gl_link')
+ array('insert'=>true, 'fun'=> 'prt_link')
);
$table =& new_db_pager('orders_tbl', $sql, $cols);
function get_grn_items($grn_batch_id=0, $supplier_id="", $outstanding_only=false,
$is_invoiced_only=false, $invoice_no=0, $begin="", $end="")
{
- $sql = "SELECT grn.*, grn_item.*,
+ $sql = "SELECT grn.*, grn_item.*, po_item.delivery_date as req_del_date,
grn_item.quantity_inv".($invoice_no ? "-invoice_item.quantity" : '')." quantity_inv,
po_item.unit_price,
po_item.act_price,
$order->add_to_order($order->lines_on_order, $myrow["item_code"],
$myrow["qty_recd"],$myrow["description"], $myrow["unit_price"],$units,
- sql2date($myrow["delivery_date"]), $myrow["quantity_inv"],
+ sql2date($myrow["req_del_date"]), $myrow["quantity_inv"],
$myrow["qty_recd"]);
$order->line_items[$order->lines_on_order-1]->po_detail_rec = $myrow["po_detail_item"];
$sql = "SELECT supp.supp_name, terms.terms, terms.days_before_due, supp.dimension_id, supp.dimension2_id,
terms.day_in_following_month, supp.tax_included,
supp.tax_group_id, tax_group.name AS tax_group_name,
- supp.credit_limit - Sum((ov_amount + ov_gst + ov_discount)) as cur_credit
+ supp.credit_limit - Sum((ov_amount + ov_gst + ov_discount)) as cur_credit, curr_code
FROM ".TB_PREF."suppliers supp LEFT JOIN "
.TB_PREF."supp_trans trans ON supp.supplier_id = trans.supplier_id, "
.TB_PREF."payment_terms terms, "
$supp_trans->tax_group_id = $myrow['tax_group_id'];
$supp_trans->dimension = $myrow['dimension_id'];
$supp_trans->dimension2 = $myrow['dimension2_id'];
+ $supp_trans->currency = $myrow['curr_code'];
}
} else
$allocs = get_po_prepayments($supp_trans);
- add_new_exchange_rate($supplier['curr_code'], $supp_trans->tran_date, $supp_trans->ex_rate);
+ add_new_exchange_rate($supp_trans->currency, $supp_trans->tran_date, $supp_trans->ex_rate);
foreach ($taxes as $n => $taxitem)
{
}
$date_ = $supp_trans->tran_date;
- $ex_rate = get_exchange_rate_from_home_currency($supplier['curr_code'], $date_);
+ $ex_rate = get_exchange_rate_from_home_currency($supp_trans->currency, $date_);
/*First insert the invoice into the supp_trans table*/
$invoice_id = write_supp_trans($trans_type, 0, $supp_trans->supplier_id, $date_, $supp_trans->due_date,
$dim, $dim2, $taxfree_line, $supp_trans->supplier_id);
else
{
- $ex_rate = get_exchange_rate_from_home_currency($supplier['curr_code'], $old_date);
+ $ex_rate = get_exchange_rate_from_home_currency($supp_trans->currency, $old_date);
$old_value = get_tax_free_price_for_item($entered_grn->item_code, $entered_grn->this_quantity_inv * $old_price,
$supp_trans->tax_group_id, $supp_trans->tax_included);
function read_supp_invoice($trans_no, $trans_type, &$supp_trans)
{
- $sql = "SELECT trans.*, supp_name, dimension_id, dimension2_id
+ $sql = "SELECT trans.*, supp_name, dimension_id, dimension2_id, curr_code
FROM ".TB_PREF."supp_trans trans,"
.TB_PREF."suppliers sup
WHERE trans_no = ".db_escape($trans_no)." AND type = ".db_escape($trans_type)."
$supp_trans->tax_included = $trans_row["tax_included"];
$supp_trans->dimension = $trans_row["dimension_id"];
$supp_trans->dimension2 = $trans_row["dimension2_id"];
+ $supp_trans->currency = $trans_row["curr_code"];
$id = $trans_row["trans_no"];
porder.ord_date,
supplier.curr_code,
Sum(line.unit_price*line.quantity_ordered) AS OrderValue,
+ Sum(line.delivery_date < '". date2sql(Today()) ."'
+ AND (line.quantity_ordered > line.quantity_received)) As OverDue,
porder.into_stock_location,
chk.isopen
FROM ".TB_PREF."purch_orders as porder
function add_grn_to_trans($grn_item_id, $po_detail_item, $item_code, $item_description,
$qty_recd, $prev_quantity_inv, $this_quantity_inv, $order_price, $chg_price,
- $std_cost_unit, $gl_code)
+ $std_cost_unit=null, $gl_code='')
{
$this->grn_items[$grn_item_id] = new grn_item($grn_item_id, $po_detail_item,
$item_code, $item_description, $qty_recd, $prev_quantity_inv, $this_quantity_inv,
label_cells(_("For Purchase Order"), get_trans_view_str(ST_PURCHORDER, $po->order_no),
"class='tableheader2'");
- label_cells(_("Ordered On"), $po->orig_order_date, "class='tableheader2'");
+ label_cells(_("Delivery Date"), $po->orig_order_date, "class='tableheader2'"); // FIXME: delivery date
end_row();
start_row();
set_global_supplier($_POST['supplier_id']);
- $supplier_currency = get_supplier_currency($supp_trans->supplier_id);
-
$company_currency = get_company_currency();
- if ($supplier_currency != $company_currency)
+ if ($supp_trans->currency != $company_currency)
{
- label_row(_("Supplier's Currency:"), "<b>" . $supplier_currency . "</b>");
- exchange_rate_display($company_currency, $supplier_currency, $_POST['tran_date']);
+ label_row(_("Supplier's Currency:"), "<b>" . $supp_trans->currency . "</b>");
+ exchange_rate_display($company_currency, $supp_trans->currency, $_POST['tran_date']);
}
label_row(_("Tax Group:"), $supp_trans->tax_description);
hidden('item_description'.$n, $myrow["description"]);
hidden('prev_quantity_inv'.$n, $myrow['quantity_inv']);
hidden('order_price'.$n, $myrow['unit_price']);
- hidden('std_cost_unit'.$n, $myrow['std_cost_unit']);
hidden('po_detail_item'.$n, $myrow['po_detail_item']);
label_cell(get_trans_view_str(ST_PURCHORDER, $myrow["purch_order_no"]), "nowrap align='right'");
label_cell($myrow["item_code"]);
alt_table_row_color($k);
$grn_batch = get_grn_batch_from_item($entered_grn->id);
- label_cell(get_trans_view_str(ST_SUPPRECEIVE, $grn_batch));
+ label_cell(get_trans_view_str(ST_SUPPRECEIVE, $grn_batch), "nowrap align='right'");
if ($mode == 1)
{
// label_cell($entered_grn->id);
$row = get_grn_batch($grn_batch);
- label_cell(get_trans_view_str(ST_PURCHORDER, $row["purch_order_no"])); // PO
+ label_cell(get_trans_view_str(ST_PURCHORDER, $row["purch_order_no"]), "nowrap align='right'"); // PO
}
label_cell($entered_grn->item_code);
label_cell($entered_grn->item_description);
if ($order->trans_type==ST_SUPPINVOICE)
date_row(_("Due Date:"), 'due_date', '', false, 0, 0, 0, null, true);
- text_row(_("Supplier's Reference:"), 'supp_ref', null, 16, 15);
+ text_row(_("Supplier's Reference:"), 'supp_ref', null, 20, 60);
if (get_company_pref('use_dimension'))
dimensions_list_row(_('Dimension').':', 'dimension', null, true, _('Default'), false, 1);
_("Currency") => array('align'=>'center'),
_("Order Total") => 'amount',
array('insert'=>true, 'fun'=>'edit_link'),
- array('insert'=>true, 'fun'=>'prt_link'),
- array('insert'=>true, 'fun'=>'receive_link')
+ array('insert'=>true, 'fun'=>'receive_link'),
+ array('insert'=>true, 'fun'=>'prt_link')
);
if (get_post('StockLocation') != ALL_TEXT) {
trans_editor_link(ST_PURCHORDER, $row["order_no"]);
}
+function receive_link($row)
+{
+ global $page_nested;
+
+ return $page_nested || !$row['OverDue'] ? '' :
+ pager_link( _("Receive"),
+ "/purchasing/po_receive_items.php?PONumber=" . $row["order_no"], ICON_RECEIVE);
+}
+
function prt_link($row)
{
return print_document_link($row['order_no'], _("Print"), true, ST_PURCHORDER, ICON_PRINT);
_("Currency") => array('align'=>'center'),
_("Order Total") => 'amount',
array('insert'=>true, 'fun'=>'edit_link'),
- array('insert'=>true, 'fun'=>'prt_link'),
+ array('insert'=>true, 'fun'=>'receive_link'),
+ array('insert'=>true, 'fun'=>'prt_link')
);
if (get_post('StockLocation') != ALL_TEXT) {
_("Amount") => array('align'=>'right', 'fun'=>'fmt_amount'),
_("Balance") => array('align'=>'right', 'type'=>'amount'),
array('insert'=>true, 'fun'=>'gl_view'),
+ array('insert'=>true, 'fun'=>'edit_link'),
array('insert'=>true, 'fun'=>'credit_link'),
- array('insert'=>true, 'fun'=>'prt_link'),
- array('insert'=>true, 'fun'=>'edit_link')
+ array('insert'=>true, 'fun'=>'prt_link')
);
if ($_POST['supplier_id'] != ALL_TEXT)
$_POST['supplier_id'] = $_GET['supplier_id'];
}
-$supplier_id = get_post('supplier_id');
+$supplier_id = get_post('supplier_id', '');
+
+function can_process()
+{
+ /* actions to take once the user has clicked the submit button
+ ie the page has called itself with some user input */
+
+ //first off validate inputs sensible
+
+ if (strlen($_POST['supp_name']) == 0 || $_POST['supp_name'] == "")
+ {
+ display_error(_("The supplier name must be entered."));
+ set_focus('supp_name');
+ return false;
+ }
+
+ if (strlen($_POST['supp_ref']) == 0 || $_POST['supp_ref'] == "")
+ {
+ display_error(_("The supplier short name must be entered."));
+ set_focus('supp_ref');
+ return false;
+ }
+ return true;
+}
+
+function handle_submit(&$supplier_id)
+{
+ global $path_to_root, $Ajax, $SysPrefs;
+
+ if (!can_process())
+ return;
+ begin_transaction();
+ if ($supplier_id)
+ {
+ update_supplier($_POST['supplier_id'], $_POST['supp_name'], $_POST['supp_ref'], $_POST['address'],
+ $_POST['supp_address'], $_POST['gst_no'],
+ $_POST['website'], $_POST['supp_account_no'], $_POST['bank_account'],
+ input_num('credit_limit', 0), $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['curr_code'],
+ $_POST['payment_terms'], $_POST['payable_account'], $_POST['purchase_account'], $_POST['payment_discount_account'],
+ $_POST['notes'], $_POST['tax_group_id'], check_value('tax_included'));
+ update_record_status($_POST['supplier_id'], $_POST['inactive'],
+ 'suppliers', 'supplier_id');
+
+ $Ajax->activate('supplier_id'); // in case of status change
+ display_notification(_("Supplier has been updated."));
+ }
+ else
+ {
+ add_supplier($_POST['supp_name'], $_POST['supp_ref'], $_POST['address'], $_POST['supp_address'],
+ $_POST['gst_no'], $_POST['website'], $_POST['supp_account_no'], $_POST['bank_account'],
+ input_num('credit_limit',0), $_POST['dimension_id'], $_POST['dimension2_id'],
+ $_POST['curr_code'], $_POST['payment_terms'], $_POST['payable_account'], $_POST['purchase_account'],
+ $_POST['payment_discount_account'], $_POST['notes'], $_POST['tax_group_id'], check_value('tax_included'));
+
+ $supplier_id = $_POST['supplier_id'] = db_insert_id();
+
+ add_crm_person($_POST['supp_ref'], $_POST['contact'], '', $_POST['address'],
+ $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'],
+ $_POST['rep_lang'], '');
+
+ add_crm_contact('supplier', 'general', $supplier_id, db_insert_id());
+
+ display_notification(_("A new supplier has been added."));
+ $Ajax->activate('_page_body');
+ }
+ commit_transaction();
+}
+
+if (isset($_POST['submit']))
+{
+ handle_submit($supplier_id);
+}
+
+if (isset($_POST['delete']) && $_POST['delete'] != "")
+{
+ //the link to delete a selected record was clicked instead of the submit button
+
+ $cancel_delete = 0;
+
+ // PREVENT DELETES IF DEPENDENT RECORDS IN 'supp_trans' , purch_orders
+
+ if (key_in_foreign_table($_POST['supplier_id'], 'supp_trans', 'supplier_id'))
+ {
+ $cancel_delete = 1;
+ display_error(_("Cannot delete this supplier because there are transactions that refer to this supplier."));
+
+ }
+ else
+ {
+ if (key_in_foreign_table($_POST['supplier_id'], 'purch_orders', 'supplier_id'))
+ {
+ $cancel_delete = 1;
+ display_error(_("Cannot delete the supplier record because purchase orders have been created against this supplier."));
+ }
+
+ }
+ if ($cancel_delete == 0)
+ {
+ delete_supplier($_POST['supplier_id']);
+
+ unset($_SESSION['supplier_id']);
+ $supplier_id = '';
+ $Ajax->activate('_page_body');
+ display_notification("#" . $_POST['supplier_id'] . " " . _("Supplier has been deleted."));
+ } //end if Delete supplier
+}
+
//--------------------------------------------------------------------------------------------
function supplier_settings(&$supplier_id)
{
}
else
{
- $_POST['supp_name'] = $_POST['supp_ref'] = $_POST['address'] = $_POST['supp_address'] =
- $_POST['tax_group_id'] = $_POST['website'] = $_POST['supp_account_no'] = $_POST['notes'] = '';
- $_POST['dimension_id'] = 0;
- $_POST['dimension2_id'] = 0;
- $_POST['tax_included'] = 0;
- $_POST['sales_type'] = -1;
- $_POST['gst_no'] = $_POST['bank_account'] = '';
- $_POST['payment_terms'] = '';
- $_POST['credit_limit'] = price_format(0);
-
- $company_record = get_company_prefs();
- $_POST['curr_code'] = $company_record["curr_default"];
- $_POST['payable_account'] = $company_record["creditors_act"];
- $_POST['purchase_account'] = ''; // default/item's cogs account
- $_POST['payment_discount_account'] = $company_record['pyt_discount_act'];
+ if (list_updated('supplier_id') || !isset($_POST['supp_name'])) {
+ $_POST['supp_name'] = $_POST['supp_ref'] = $_POST['address'] = $_POST['supp_address'] =
+ $_POST['tax_group_id'] = $_POST['website'] = $_POST['supp_account_no'] = $_POST['notes'] = '';
+ $_POST['dimension_id'] = 0;
+ $_POST['dimension2_id'] = 0;
+ $_POST['tax_included'] = 0;
+ $_POST['sales_type'] = -1;
+ $_POST['gst_no'] = $_POST['bank_account'] = '';
+ $_POST['payment_terms'] = '';
+ $_POST['credit_limit'] = price_format(0);
+
+ $company_record = get_company_prefs();
+ $_POST['curr_code'] = $company_record["curr_default"];
+ $_POST['payable_account'] = $company_record["creditors_act"];
+ $_POST['purchase_account'] = ''; // default/item's cogs account
+ $_POST['payment_discount_account'] = $company_record['pyt_discount_act'];
+ }
}
table_section_title(_("Basic Data"));
- text_row(_("Supplier Name:"), 'supp_name', null, 42, 40);
+ text_row(_("Supplier Name:"), 'supp_name', null, 42, 60);
text_row(_("Supplier Short Name:"), 'supp_ref', null, 30, 30);
text_row(_("GSTNo:"), 'gst_no', null, 42, 40);
div_end();
}
-if (isset($_POST['submit']))
-{
-
- //initialise no input errors assumed initially before we test
- $input_error = 0;
-
- /* actions to take once the user has clicked the submit button
- ie the page has called itself with some user input */
-
- //first off validate inputs sensible
-
- if (strlen($_POST['supp_name']) == 0 || $_POST['supp_name'] == "")
- {
- $input_error = 1;
- display_error(_("The supplier name must be entered."));
- set_focus('supp_name');
- }
-
- if (strlen($_POST['supp_ref']) == 0 || $_POST['supp_ref'] == "")
- {
- $input_error = 1;
- display_error(_("The supplier short name must be entered."));
- set_focus('supp_ref');
- }
-
- if ($input_error !=1 )
- {
-
- begin_transaction();
- if ($supplier_id)
- {
- update_supplier($_POST['supplier_id'], $_POST['supp_name'], $_POST['supp_ref'], $_POST['address'],
- $_POST['supp_address'], $_POST['gst_no'],
- $_POST['website'], $_POST['supp_account_no'], $_POST['bank_account'],
- input_num('credit_limit', 0), $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['curr_code'],
- $_POST['payment_terms'], $_POST['payable_account'], $_POST['purchase_account'], $_POST['payment_discount_account'],
- $_POST['notes'], $_POST['tax_group_id'], check_value('tax_included'));
- update_record_status($_POST['supplier_id'], $_POST['inactive'],
- 'suppliers', 'supplier_id');
-
- $Ajax->activate('supplier_id'); // in case of status change
- display_notification(_("Supplier has been updated."));
- }
- else
- {
- add_supplier($_POST['supp_name'], $_POST['supp_ref'], $_POST['address'], $_POST['supp_address'],
- $_POST['gst_no'], $_POST['website'], $_POST['supp_account_no'], $_POST['bank_account'],
- input_num('credit_limit',0), $_POST['dimension_id'], $_POST['dimension2_id'],
- $_POST['curr_code'], $_POST['payment_terms'], $_POST['payable_account'], $_POST['purchase_account'],
- $_POST['payment_discount_account'], $_POST['notes'], $_POST['tax_group_id'], check_value('tax_included'));
-
- $supplier_id = $_POST['supplier_id'] = db_insert_id();
-
- add_crm_person($_POST['supp_ref'], $_POST['contact'], '', $_POST['address'],
- $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'],
- $_POST['rep_lang'], '');
-
- add_crm_contact('supplier', 'general', $supplier_id, db_insert_id());
-
- display_notification(_("A new supplier has been added."));
- $Ajax->activate('_page_body');
- }
- commit_transaction();
- }
-
-}
-elseif (isset($_POST['delete']) && $_POST['delete'] != "")
-{
- //the link to delete a selected record was clicked instead of the submit button
-
- $cancel_delete = 0;
-
- // PREVENT DELETES IF DEPENDENT RECORDS IN 'supp_trans' , purch_orders
-
- if (key_in_foreign_table($_POST['supplier_id'], 'supp_trans', 'supplier_id'))
- {
- $cancel_delete = 1;
- display_error(_("Cannot delete this supplier because there are transactions that refer to this supplier."));
-
- }
- else
- {
- if (key_in_foreign_table($_POST['supplier_id'], 'purch_orders', 'supplier_id'))
- {
- $cancel_delete = 1;
- display_error(_("Cannot delete the supplier record because purchase orders have been created against this supplier."));
- }
-
- }
- if ($cancel_delete == 0)
- {
- delete_supplier($_POST['supplier_id']);
-
- unset($_SESSION['supplier_id']);
- $supplier_id = '';
- $Ajax->activate('_page_body');
- display_notification("#" . $_POST['supplier_id'] . " " . _("Supplier has been deleted."));
- } //end if Delete supplier
-}
-
start_form();
if (db_has_suppliers())
//----------------------------------------------------------------------------------------
if (isset($_GET['ModifyCredit']))
- check_is_editable(ST_SUPPINVOICE, $_GET['ModifyCredit']);
+ check_is_editable(ST_SUPPCREDIT, $_GET['ModifyCredit']);
//---------------------------------------------------------------------------------------------------
$_POST['po_detail_item'.$n], $_POST['item_code'.$n],
$_POST['item_description'.$n], $_POST['qty_recd'.$n],
$_POST['prev_quantity_inv'.$n], input_num('This_QuantityCredited'.$n),
- $_POST['order_price'.$n], input_num('ChgPrice'.$n),
- $_POST['std_cost_unit'.$n], "");
+ $_POST['order_price'.$n], input_num('ChgPrice'.$n));
reset_tax_input();
}
}
{
if (check_item_data($n))
{
- if (input_num('this_quantity_inv'.$n) >= ($_POST['qty_recd'.$n] - $_POST['prev_quantity_inv'.$n]))
- {
- $complete = true;
- }
- else
- {
- $complete = false;
- }
-
$_SESSION['supp_trans']->add_grn_to_trans($n, $_POST['po_detail_item'.$n],
$_POST['item_code'.$n], $_POST['item_description'.$n], $_POST['qty_recd'.$n],
$_POST['prev_quantity_inv'.$n], input_num('this_quantity_inv'.$n),
- $_POST['order_price'.$n], input_num('ChgPrice'.$n), $complete,
- $_POST['std_cost_unit'.$n], "");
+ $_POST['order_price'.$n], input_num('ChgPrice'.$n));
reset_tax_input();
}
}
display_heading2(_("Line Details"));
start_table(TABLESTYLE, "width='90%'");
-$th = array(_("Item Code"), _("Item Description"), _("Delivery Date"), _("Quantity"),
+$th = array(_("Item Code"), _("Item Description"), _("Required by"), _("Quantity"),
_("Unit"), _("Price"), _("Line Total"), _("Quantity Invoiced"));
table_header($th);
$total = 0;
$k = 0; //row colour counter
+$overdue_items = false;
foreach ($purchase_order->line_items as $stock_item)
{
$line_total = $stock_item->qty_received * $stock_item->price;
- alt_table_row_color($k);
+ // if overdue and outstanding quantities, then highlight as so
+ if (date1_greater_date2($purchase_order->orig_order_date, $stock_item->req_del_date))
+ {
+ start_row("class='overduebg'");
+ $overdue_items = true;
+ }
+ else
+ {
+ alt_table_row_color($k);
+ }
label_cell($stock_item->stock_id);
label_cell($stock_item->item_description);
end_table(1);
+if ($overdue_items)
+ display_note(_("Marked items were delivered overdue."), 0, 0, "class='overduefg'");
+
is_voided_display(ST_SUPPRECEIVE, $_GET['trans_no'], _("This delivery has been voided."));
end_page(true, false, false, ST_SUPPRECEIVE, $_GET['trans_no']);
$align = 'J';
}
else
- $align = 'R';
+ {
+ if ($align == 'right')
+ $align = 'R';// This may need to be 'L'
+ elseif ($align == 'left')
+ $align = 'R';
+ elseif ($align == 'center')
+ $align = 'C';
+ elseif ($align == 'justify')
+ $align = 'J';
+ }
$txt = parent::unhtmlentities($txt);
// If horizontal scaling was requested, check to see if we're trying to scale
// too much. If so, cut back string first and then scale it.
$maxScaleFactor = 1.4;
if ($stretch == 1 || $stretch == 2)
- $txt = $this->calcTextWrap($txt, $w * $maxScaleFactor, $spacebreak);
+ $txt = $this->calcTextWrap($txt, $w * $maxScaleFactor, $spacebreak);
// Wrap text if stretching isn't turned on
else
- $txt = $this->calcTextWrap($txt, $w, $spacebreak);
+ $txt = $this->calcTextWrap($txt, $w, $spacebreak);
$ret = $txt[1];
$txt = $txt[0];
$this->SetXY($xb, $this->h - $yb - $h);
'PARAM_3' => '',
'PARAM_4' => $def_orientation);
break;
+ case ST_DIMENSION :
+ $rep = 501;
+ // from, to, email, comments, orientation
+ $ar = array(
+ 'PARAM_0' => $doc_no,
+ 'PARAM_1' => $doc_no,
+ 'PARAM_2' => 1,
+ 'PARAM_3' => '',
+ 'PARAM_4' => $def_orientation);
+ break;
default:
return null;
}
".TB_PREF."salesman salesman
WHERE sorder.order_no=trans.order_
AND sorder.branch_code=branch.branch_code
+ AND sorder.trans_type = ".ST_SALESORDER."
AND branch.salesman=salesman.salesman_code
AND trans.debtor_no=cust.debtor_no
AND (trans.type=".ST_SALESINVOICE." OR trans.type=".ST_CUSTCREDIT.")
OR (type=".ST_JOURNAL. " AND (trans.ov_amount < 0)))";
if (!$settled)
- $sql .= " AND (round(abs(ov_amount+ov_gst+ov_freight+ov_freight_tax-ov_discount-alloc),6) > 0)";
+ $sql .= " AND (round(abs(ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount-alloc),6) > 0)";
if ($customer_id != null)
$sql .= " AND trans.debtor_no = ".db_escape($customer_id);
hidden('stock_id', $_POST['stock_id']);
label_cell($_POST['stock_id']);
if ($order->line_items[$id]->descr_editable)
- text_cells(null,'item_description', null, 45, 150);
+ text_cells(null,'item_description', null, 45, 50);
else {
hidden('item_description', $_POST['item_description']);
label_cell($_POST['item_description']);
if ($page_nested)
return '';
- return $row['type'] == ST_SALESINVOICE && $row["Outstanding"] > 0 ?
- pager_link(_("Credit This") ,
- "/sales/customer_credit_invoice.php?InvoiceNumber=". $row['trans_no'], ICON_CREDIT):'';
+ if ($row["Outstanding"] > 0)
+ {
+ if ($row['type'] == ST_CUSTDELIVERY)
+ return pager_link(_('Invoice'), "/sales/customer_invoice.php?DeliveryNumber="
+ .$row['trans_no'], ICON_DOC);
+ else if ($row['type'] == ST_SALESINVOICE)
+ return pager_link(_("Credit This") ,
+ "/sales/customer_credit_invoice.php?InvoiceNumber=". $row['trans_no'], ICON_CREDIT);
+ }
}
function edit_link($row)
_("Amount") => array('align'=>'right', 'fun'=>'fmt_amount'),
_("Balance") => array('align'=>'right', 'type'=>'amount'),
array('insert'=>true, 'fun'=>'gl_view'),
- array('insert'=>true, 'fun'=>'credit_link'),
array('insert'=>true, 'fun'=>'edit_link'),
+ array('insert'=>true, 'fun'=>'credit_link'),
array('insert'=>true, 'fun'=>'prt_link')
);
function dispatch_link($row)
{
- global $trans_type;
+ global $trans_type, $page_nested;
if ($row['ord_payments'] + $row['inv_payments'] < $row['prep_amount'])
return '';
if ($trans_type == ST_SALESORDER)
- return pager_link( _("Dispatch"),
- "/sales/customer_delivery.php?OrderNumber=" .$row['order_no'], ICON_DOC);
+ {
+ if ($row['TotDelivered'] < $row['TotQuantity'] && !$page_nested)
+ return pager_link( _("Dispatch"),
+ "/sales/customer_delivery.php?OrderNumber=" .$row['order_no'], ICON_DOC);
+ else
+ return '';
+ }
else
return pager_link( _("Sales Order"),
"/sales/sales_order_entry.php?OrderNumber=" .$row['order_no'], ICON_DOC);
);
if ($_POST['order_view_mode'] == 'OutstandingOnly') {
array_append($cols, array(
+ array('insert'=>true, 'fun'=>'edit_link'),
array('insert'=>true, 'fun'=>'dispatch_link'),
- array('insert'=>true, 'fun'=>'edit_link')));
+ array('insert'=>true, 'fun'=>'prt_link')));
} elseif ($_POST['order_view_mode'] == 'InvoiceTemplates') {
array_substitute($cols, 4, 1, _("Description"));
array_append($cols,array(
_("Tmpl") => array('insert'=>true, 'fun'=>'tmpl_checkbox'),
array('insert'=>true, 'fun'=>'edit_link'),
+ array('insert'=>true, 'fun'=>'dispatch_link'),
array('insert'=>true, 'fun'=>'prt_link')));
};