$type = ($row['filetype']) ? $row['filetype'] : 'application/octet-stream';
header("Content-type: ".$type);
header('Content-Length: '.$row['filesize']);
- header('Content-Disposition: attachment; filename='.$row['filename']);
+ header('Content-Disposition: attachment; filename="'.$row['filename'].'"');
echo file_get_contents(company_path()."/attachments/".$row['unique_name']);
exit();
}
if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM')
{
+
+ if($_POST['filterType'] == ST_CUSTOMER){
+ $_POST['trans_no'] = $_POST['customer_id'];
+ }elseif($_POST['filterType'] == ST_SUPPLIER){
+ $_POST['trans_no'] = $_POST['supplier_id'];
+ }
+
if (!transaction_exists($_POST['filterType'], $_POST['trans_no']))
display_error(_("Selected transaction does not exists."));
elseif ($Mode == 'ADD_ITEM' && !isset($_FILES['filename']))
if (list_updated('filterType'))
$selected_id = -1;
+ if(get_post('filterType') == ST_CUSTOMER ){
+ customer_list_cells(_("Select a customer: "), 'customer_id', null, _('Select customer'), true, true);
+ } elseif(get_post('filterType') == ST_SUPPLIER){
+ supplier_list_cells(_("Select a supplier: "), 'supplier_id', null, _('Select supplier'), true,true);
+ }
+
end_row();
end_table(1);
return button('Delete'.$row["id"], _("Delete"), _("Delete"), ICON_DELETE);
}
-function display_rows($type)
+function display_rows($type, $id_no)
{
- $sql = get_sql_for_attached_documents($type);
+ $sql = get_sql_for_attached_documents($type, $id_no);
$cols = array(
_("#") => array('fun'=>'trans_view', 'ord'=>''),
_("Description") => array('name'=>'description'),
start_form(true);
viewing_controls();
-
-display_rows($_POST['filterType']);
+$id_no = ($_POST['filterType'] == ST_CUSTOMER) ? get_post('customer_id') : get_post('supplier_id');
+display_rows($_POST['filterType'], $id_no);
br(2);
}
hidden('selected_id', $selected_id);
}
-else
- text_row_ex(_("Transaction #").':', 'trans_no', 10);
+else {
+ if( $id_no == 0 )
+ text_row_ex(_("Transaction #").':', 'trans_no', 10);
+ else
+ hidden('trans_no', $id_no);
+}
text_row_ex(_("Description").':', 'description', 40);
file_row(_("Attached File") . ":", 'filename', 'filename');
.db_escape($trans_no).",".db_escape($description).", "
.db_escape($filename).", ".db_escape($unique_name).", ".db_escape($filesize)
.", ".db_escape($filetype).", '$date')";
- db_query($sql, "Attachment could not be inserted");
+ db_query($sql, "Attachment could not be inserted");
}
//----------------------------------------------------------------------------------------
filetype=".db_escape($filetype).",";
}
$sql .= "tran_date='$date' WHERE id=".db_escape($selected_id);
- db_query($sql, "Attachment could not be updated");
+ db_query($sql, "Attachment could not be updated");
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
-function get_attached_documents($type)
+function get_attached_documents($type, $trans_no=false)
{
- $sql = "SELECT * FROM ".TB_PREF."attachments WHERE type_no=".db_escape($type)
- ." ORDER BY trans_no";
+ $sql = "SELECT * FROM ".TB_PREF."attachments WHERE type_no=".db_escape($type);
+ if ($trans_no)
+ $sql .= " AND trans_no=".db_escape($trans_no);
+ $sql .= " ORDER BY trans_no";
return db_query($sql, "Could not retrieve attachments");
}
return $myrow['id'];
}
-function get_sql_for_attached_documents($type)
+function get_sql_for_attached_documents($type, $id_no)
{
- return "SELECT trans_no, description, filename, filesize, filetype, tran_date, id, type_no FROM ".TB_PREF."attachments WHERE type_no=".db_escape($type)
- ." ORDER BY trans_no DESC";
+ // $_POST['trans_no'] will be used to store the customer_id or supplier_id for them
+ $sql = "SELECT trans_no, description, filename, filesize, filetype, tran_date, id, type_no FROM ".TB_PREF."attachments WHERE type_no=".db_escape($type);
+
+ if(($type == ST_CUSTOMER || $type == ST_SUPPLIER) && $id_no != null)
+ $sql .=" AND trans_no = ".db_escape($id_no);
+
+ $sql .= " ORDER BY trans_no DESC";
+
+ return $sql;
}
function move_trans_attachments($type, $trans_from, $trans_to)
case ST_SALESQUOTE : return array(TB_PREF."sales_orders", "trans_type", "order_no", "reference", "ord_date");
case ST_DIMENSION : return array(TB_PREF."dimensions", null, "id", "reference", "date_");
case ST_COSTUPDATE : return array(TB_PREF."journal", "type", "trans_no", "reference", "tran_date");
+
+ case ST_CUSTOMER : return array(TB_PREF."debtors_master", null, "debtor_no", "debtor_ref", null);
+ case ST_SUPPLIER : return array(TB_PREF."suppliers", null, "supplier_id", "supp_ref", null);
}
display_db_error("invalid type ($type) sent to get_systype_db_info", "", true);
ST_SALESQUOTE => _("Sales Quotation"),
ST_COSTUPDATE => _("Cost Update"),
ST_DIMENSION => _("Dimension"),
+ ST_CUSTOMER => _("Customer"),
+ ST_SUPPLIER => _("Supplier"),
);
$fa_systypes_array = array (
define('ST_SALESQUOTE', 32);
define('ST_COSTUPDATE', 35);
define('ST_DIMENSION', 40);
+define('ST_CUSTOMER', 41);
+define('ST_SUPPLIER', 42);
// Don't include these defines in the $systypes_array.
// They are used for documents only.
$path_to_root = "../..";
include($path_to_root . "/includes/db_pager.inc");
include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/includes/ui/attachment.inc");
$js = "";
if ($SysPrefs->use_popup_windows)
$js .= get_js_open_window(900, 500);
if ($supplier_id)
{
submit_center_first('submit', _("Update Supplier"),
- _('Update supplier data'), $page_nested ? true : 'default');
+ _('Update supplier data'), $page_nested ? true : 'false');
submit_return('select', get_post('supplier_id'), _("Select this supplier and return to document entry."));
submit_center_last('delete', _("Delete Supplier"),
_('Delete supplier data if have been never used'), true);
}
else
{
- submit_center('submit', _("Add New Supplier Details"), true, '', 'default');
+ submit_center('submit', _("Add New Supplier Details"), true, '', 'false');
}
div_end();
}
-start_form();
+start_form(true);
if (db_has_suppliers())
{
'contacts' => array(_('&Contacts'), $supplier_id),
'transactions' => array(_('&Transactions'), (user_check_access('SA_SUPPTRANSVIEW') ? $supplier_id : null)),
'orders' => array(_('Purchase &Orders'), (user_check_access('SA_SUPPTRANSVIEW') ? $supplier_id : null)),
+ 'attachments' => array(_('Attachments'), (user_check_access('SA_ATTACHDOCUMENT') ? $supplier_id : null)),
));
switch (get_post('_tabs_sel')) {
$_GET['supplier_id'] = $supplier_id;
include_once($path_to_root."/purchasing/inquiry/po_search_completed.php");
break;
+ case 'attachments':
+ $_GET['trans_no'] = $supplier_id;
+ $_GET['type_no']= ST_SUPPLIER;
+ $attachments = new attachments('attachment', $supplier_id, 'suppliers');
+ $attachments->show();
};
br();
tabbed_content_end();
include_once($path_to_root . "/includes/banking.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/ui/contacts_view.inc");
+include_once($path_to_root . "/includes/ui/attachment.inc");
if (isset($_GET['debtor_no']))
{
if (@$_REQUEST['popup']) hidden('popup', 1);
if (!$selected_id)
{
- submit_center('submit', _("Add New Customer"), true, '', 'default');
+ submit_center('submit', _("Add New Customer"), true, '', false);
}
else
{
submit_center_first('submit', _("Update Customer"),
- _('Update customer data'), $page_nested ? true : 'default');
+ _('Update customer data'), $page_nested ? true : false);
submit_return('select', $selected_id, _("Select this customer and return to document entry."));
submit_center_last('delete', _("Delete Customer"),
_('Delete customer data if have been never used'), true);
check_db_has_sales_types(_("There are no sales types defined. Please define at least one sales type before adding a customer."));
-start_form();
+start_form(true);
if (db_has_customers())
{
'contacts' => array(_('&Contacts'), $selected_id),
'transactions' => array(_('&Transactions'), (user_check_access('SA_SALESTRANSVIEW') ? $selected_id : null)),
'orders' => array(_('Sales &Orders'), (user_check_access('SA_SALESTRANSVIEW') ? $selected_id : null)),
+ 'attachments' => array(_('Attachments'), (user_check_access('SA_ATTACHDOCUMENT') ? $selected_id : null)),
));
switch (get_post('_tabs_sel')) {
$_GET['customer_id'] = $selected_id;
include_once($path_to_root."/sales/inquiry/sales_orders_view.php");
break;
+ case 'attachments':
+ $_GET['trans_no'] = $selected_id;
+ $_GET['type_no']= ST_CUSTOMER;
+ $attachments = new attachments('attachment', $selected_id, 'customers');
+ $attachments->show();
};
br();
tabbed_content_end();