projects
/
fa-stable.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
44a7cb9
)
Added new attachment types for customer and supplier specific documents.
author
Janusz Dobrowolski
<janusz@frontaccounting.eu>
Mon, 7 Oct 2019 21:40:55 +0000
(23:40 +0200)
committer
Janusz Dobrowolski
<janusz@frontaccounting.eu>
Wed, 9 Oct 2019 20:05:20 +0000
(22:05 +0200)
admin/attachments.php
patch
|
blob
|
history
admin/db/attachments_db.inc
patch
|
blob
|
history
admin/db/transactions_db.inc
patch
|
blob
|
history
includes/sysnames.inc
patch
|
blob
|
history
includes/types.inc
patch
|
blob
|
history
purchasing/manage/suppliers.php
patch
|
blob
|
history
sales/manage/customers.php
patch
|
blob
|
history
diff --git
a/admin/attachments.php
b/admin/attachments.php
index e92276ed87fd2934596504ff9147e178394a4542..565e4b1ed836e7b177c3a36974ce04f0930fd5c8 100644
(file)
--- a/
admin/attachments.php
+++ b/
admin/attachments.php
@@
-58,7
+58,7
@@
if ($download_id != -1)
$type = ($row['filetype']) ? $row['filetype'] : 'application/octet-stream';
header("Content-type: ".$type);
header('Content-Length: '.$row['filesize']);
$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();
}
echo file_get_contents(company_path()."/attachments/".$row['unique_name']);
exit();
}
@@
-79,6
+79,13
@@
if (isset($_GET['trans_no']))
if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM')
{
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 (!transaction_exists($_POST['filterType'], $_POST['trans_no']))
display_error(_("Selected transaction does not exists."));
elseif ($Mode == 'ADD_ITEM' && !isset($_FILES['filename']))
@@
-171,6
+178,12
@@
function viewing_controls()
if (list_updated('filterType'))
$selected_id = -1;
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);
end_row();
end_table(1);
@@
-201,9
+214,9
@@
function delete_link($row)
return button('Delete'.$row["id"], _("Delete"), _("Delete"), ICON_DELETE);
}
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'),
$cols = array(
_("#") => array('fun'=>'trans_view', 'ord'=>''),
_("Description") => array('name'=>'description'),
@@
-228,8
+241,8
@@
function display_rows($type)
start_form(true);
viewing_controls();
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);
br(2);
@@
-248,8
+261,12
@@
if ($selected_id != -1)
}
hidden('selected_id', $selected_id);
}
}
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');
text_row_ex(_("Description").':', 'description', 40);
file_row(_("Attached File") . ":", 'filename', 'filename');
diff --git
a/admin/db/attachments_db.inc
b/admin/db/attachments_db.inc
index f3c46dc41332c28b89d32b3d2be59bf40a59efcd..77d8d91e5aa088b0c06cd06b1f1923291c5b67d9 100644
(file)
--- a/
admin/db/attachments_db.inc
+++ b/
admin/db/attachments_db.inc
@@
-21,7
+21,7
@@
function add_attachment($filterType, $trans_no, $description,
.db_escape($trans_no).",".db_escape($description).", "
.db_escape($filename).", ".db_escape($unique_name).", ".db_escape($filesize)
.", ".db_escape($filetype).", '$date')";
.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");
}
//----------------------------------------------------------------------------------------
}
//----------------------------------------------------------------------------------------
@@
-41,7
+41,7
@@
function update_attachment($selected_id, $filterType, $trans_no, $description,
filetype=".db_escape($filetype).",";
}
$sql .= "tran_date='$date' WHERE id=".db_escape($selected_id);
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");
}
//----------------------------------------------------------------------------------------
}
//----------------------------------------------------------------------------------------
@@
-72,10
+72,12
@@
function get_attachment_string($type, $id)
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
-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 db_query($sql, "Could not retrieve attachments");
}
@@
-97,10
+99,17
@@
function has_attachment($type, $id)
return $myrow['id'];
}
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)
}
function move_trans_attachments($type, $trans_from, $trans_to)
diff --git
a/admin/db/transactions_db.inc
b/admin/db/transactions_db.inc
index 466ded81ea54a9015839d9d86b03dce89a402696..a948cf3e70a1b955547a471a4f5806aa54baf6ff 100644
(file)
--- a/
admin/db/transactions_db.inc
+++ b/
admin/db/transactions_db.inc
@@
-209,6
+209,9
@@
function get_systype_db_info($type)
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_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);
}
display_db_error("invalid type ($type) sent to get_systype_db_info", "", true);
diff --git
a/includes/sysnames.inc
b/includes/sysnames.inc
index 507bd698dedecc98451c72b65190a208d8d129e9..68828bca6242f5ff5c45f40dcde5a950245fb36b 100644
(file)
--- a/
includes/sysnames.inc
+++ b/
includes/sysnames.inc
@@
-41,6
+41,8
@@
$systypes_array = array (
ST_SALESQUOTE => _("Sales Quotation"),
ST_COSTUPDATE => _("Cost Update"),
ST_DIMENSION => _("Dimension"),
ST_SALESQUOTE => _("Sales Quotation"),
ST_COSTUPDATE => _("Cost Update"),
ST_DIMENSION => _("Dimension"),
+ ST_CUSTOMER => _("Customer"),
+ ST_SUPPLIER => _("Supplier"),
);
$fa_systypes_array = array (
);
$fa_systypes_array = array (
diff --git
a/includes/types.inc
b/includes/types.inc
index 959c1cd1360a94c58c361d5b46999babe37f42fe..a47e265fc5884d272e3c96b22d2bc22af76f4e61 100644
(file)
--- a/
includes/types.inc
+++ b/
includes/types.inc
@@
-46,6
+46,8
@@
define('ST_SALESORDER', 30);
define('ST_SALESQUOTE', 32);
define('ST_COSTUPDATE', 35);
define('ST_DIMENSION', 40);
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.
// Don't include these defines in the $systypes_array.
// They are used for documents only.
diff --git
a/purchasing/manage/suppliers.php
b/purchasing/manage/suppliers.php
index 9cab778f183faccc850ebbeb39be035dbde9f8ba..b0c7c35b338523a950e38da6f53a6e94e42c3632 100644
(file)
--- a/
purchasing/manage/suppliers.php
+++ b/
purchasing/manage/suppliers.php
@@
-13,6
+13,7
@@
$page_security = 'SA_SUPPLIER';
$path_to_root = "../..";
include($path_to_root . "/includes/db_pager.inc");
include_once($path_to_root . "/includes/session.inc");
$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);
$js = "";
if ($SysPrefs->use_popup_windows)
$js .= get_js_open_window(900, 500);
@@
-279,19
+280,19
@@
function supplier_settings(&$supplier_id)
if ($supplier_id)
{
submit_center_first('submit', _("Update Supplier"),
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_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();
}
}
div_end();
}
-start_form();
+start_form(
true
);
if (db_has_suppliers())
{
if (db_has_suppliers())
{
@@
-320,6
+321,7
@@
tabbed_content_start('tabs', array(
'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)),
'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')) {
));
switch (get_post('_tabs_sel')) {
@@
-339,6
+341,11
@@
tabbed_content_start('tabs', array(
$_GET['supplier_id'] = $supplier_id;
include_once($path_to_root."/purchasing/inquiry/po_search_completed.php");
break;
$_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();
};
br();
tabbed_content_end();
diff --git
a/sales/manage/customers.php
b/sales/manage/customers.php
index 3810e2b4f2c271a0688ce61d4056c57d9d0a05e0..c81f78cbf710ebb1022d1faf143db8b6ebcc58ac 100644
(file)
--- a/
sales/manage/customers.php
+++ b/
sales/manage/customers.php
@@
-26,6
+26,7
@@
include_once($path_to_root . "/includes/date_functions.inc");
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/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 (isset($_GET['debtor_no']))
{
@@
-304,12
+305,12
@@
function customer_settings($selected_id)
if (@$_REQUEST['popup']) hidden('popup', 1);
if (!$selected_id)
{
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"),
}
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);
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);
@@
-321,7
+322,7
@@
function customer_settings($selected_id)
check_db_has_sales_types(_("There are no sales types defined. Please define at least one sales type before adding a customer."));
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())
{
if (db_has_customers())
{
@@
-352,6
+353,7
@@
tabbed_content_start('tabs', array(
'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)),
'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')) {
));
switch (get_post('_tabs_sel')) {
@@
-371,6
+373,11
@@
tabbed_content_start('tabs', array(
$_GET['customer_id'] = $selected_id;
include_once($path_to_root."/sales/inquiry/sales_orders_view.php");
break;
$_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();
};
br();
tabbed_content_end();