! -> Note
$ -> Affected files
+30-Oct-2008 Joe Hunt
+! Added Quick Entries in Bank Payments/Deposits (Banking and General Ledger).
+$ /applications/generalledger.php
+ /includes/data_checks.inc
+ /includes/types.inc
+ /includes/ui/ui_lists.inc
+ /gl/gl_bank.php
+ /gl/includes/db/gl_db_bank_accounts.inc
+ /gl/includes/ui/gl_bank_ui.inc
+ /sales/manage/customer_branches.php
+! New table, 0_quick_entries
+$ /sql/alter2.1.sql
+! Changed GL Accounts form. The tax_code is now Tax Group instead of Tax Type.
+$ /gl/manage/gl_accounts.php
+
24-Oct-2008 Janusz Dobrowolski
! Added hotkeys to final menu options.
$ /dimensions/dimension_entry.php
$this->add_module(_("Maintenance"));
$this->add_lapp_function(2, _("Bank &Accounts"),"gl/manage/bank_accounts.php?");
$this->add_lapp_function(2, _("Payment, Deposit and Transfer &Types"),"gl/manage/bank_trans_types.php?");
+ $this->add_lapp_function(2, _("Quick Entries"),"gl/manage/gl_quick_entries.php?");
$this->add_lapp_function(2, "","");
$this->add_lapp_function(2, _("&Currencies"),"gl/manage/currencies.php?");
$this->add_lapp_function(2, _("&Exchange Rates"),"gl/manage/exchange_rates.php?");
if (isset($_POST['CancelItemChanges']))
line_start_focus();
+if (isset($_POST['go']))
+{
+ if (!check_num('totamount', 0))
+ {
+ display_error( _("The amount entered is not a valid number or is less than zero."));
+ set_focus('totamount');
+ }
+ elseif (!get_post('person_id'))
+ {
+ if ($_SESSION['pay_items']->trans_type==systypes::bank_payment())
+ display_error( _("No Quick Entries are defined for Payment."));
+ else
+ display_error( _("No Quick Entries are defined for Deposit."));
+ set_focus('totamount');
+ }
+ else
+ {
+ $rate = 0;
+ $totamount = input_num('totamount');
+ $qe = get_quick_entry($_POST['person_id']);
+ $account = get_gl_account($qe['account']);
+ $tax_group = $account['tax_code'];
+ $items = get_tax_group_items($tax_group);
+ while ($item = db_fetch($items))
+ $rate += $item['rate'];
+ if ($rate != 0)
+ $totamount = $totamount * 100 / ($rate + 100);
+ $totamount = ($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? 1:-1) * $totamount;
+ $_SESSION['pay_items']->clear_items();
+ $_SESSION['pay_items']->add_gl_item($qe['account'], 0, 0, $totamount, $qe['description']);
+ $items = get_tax_group_items($tax_group);
+ while ($item = db_fetch($items))
+ {
+ if ($item['rate'] != 0)
+ {
+ $amount = $totamount * $item['rate'] / 100;
+ $code = ($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? $item['purchasing_gl_code'] :
+ $item['sales_gl_code']);
+ $_SESSION['pay_items']->add_gl_item($code, 0, 0, $amount, $qe['description']);
+ }
+ }
+ line_start_focus();
+ }
+}
//-----------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
+function add_quick_entry($description, $account, $deposit)
+{
+ $sql = "INSERT INTO ".TB_PREF."quick_entries (description, account, deposit) VALUES
+ (".db_escape($description).", ".db_escape($account).", $deposit)";
+
+ db_query($sql, "could not insert quick entry for $description");
+}
+
+//---------------------------------------------------------------------------------------------
+
+function update_quick_entry($selected_id, $description, $account, $deposit)
+{
+ $sql = "UPDATE ".TB_PREF."quick_entries SET description = ".db_escape($description).",
+ account=".db_escape($account).", deposit=$deposit
+ WHERE id = $selected_id";
+
+ db_query($sql, "could not update quick entry for $selected_id");
+}
+
+//---------------------------------------------------------------------------------------------
+
+function delete_quick_entry($selected_id)
+{
+ $sql = "DELETE FROM ".TB_PREF."quick_entries WHERE id=$selected_id";
+
+ db_query($sql,"could not delete quick entry $selected_id");
+}
+
+//---------------------------------------------------------------------------------------------
+
+function get_quick_entries($type=false)
+{
+ $sql = "SELECT ".TB_PREF."quick_entries.*, ".TB_PREF."chart_master.account_name
+ FROM ".TB_PREF."quick_entries, ".TB_PREF."chart_master WHERE
+ ".TB_PREF."quick_entries.account = ".TB_PREF."chart_master.account_code";
+ if ($type == "deposit")
+ $sql .= " AND deposit=1";
+ elseif ($type == "payment")
+ $sql .= " AND deposit=0";
+
+ return db_query($sql, "could not retreive quick entries");
+}
+
+//---------------------------------------------------------------------------------------------
+
+function get_quick_entry($selected_id)
+{
+ $sql = "SELECT * FROM ".TB_PREF."quick_entries WHERE id=$selected_id";
+
+ $result = db_query($sql, "could not retreive quick entry for $selected_id");
+
+ return db_fetch($result);
+}
+
+//---------------------------------------------------------------------------------------------
+
?>
\ No newline at end of file
hidden('PersonDetailID');
}
break;
+ case payment_person_types::QuickEntry() :
+ quick_entries_list_row(_("Description:"), 'person_id', null, $payment);
+ amount_row(_("Total Amount"), 'totamount', null, null, " ".submit('go', _("Go"), false, false, true));
+ break;
//case payment_person_types::Project() :
// dimensions_list_row(_("Dimension:"), 'person_id', $_POST['person_id'], false, null, true);
// break;
gl_account_types_list_row(_("Account Group:"), 'account_type', null);
-tax_types_list_row(_("Tax Type:"), 'tax_code', null, _('No Tax'));
+tax_groups_list_row(_("Tax Group:"), 'tax_code', null, _('No Tax'));
end_table(1);
}
}
+function db_has_quick_entries()
+{
+ return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."quick_entries");
+}
+
function check_empty_result($sql)
{
$result = db_query($sql, "could not do check empty query");
1=> array ('id' => 1, 'name' => _("Work Order")),
2=> array ('id' => 2, 'name' => _("Customer")),
3=> array ('id' => 3, 'name' => _("Supplier")),
+ 4=> array ('id' => 4, 'name' => _("Quick Entry"))
);
class payment_person_types
return 3;
}
- function dimension()
+ function QuickEntry()
{
return 4;
}
- //function Project() { return 4; }
+ function dimension()
+ {
+ return 5;
+ }
function type_name($type)
{
{
case payment_person_types::misc() :
return $person_id;
+ case payment_person_types::QuickEntry() :
+ $qe = get_quick_entry($person_id);
+ return ($full?payment_person_types::type_name($type) . " ":"") . $qe["description"];
case payment_person_types::WorkOrder() :
$wo = get_work_order($person_id);
return ($full?payment_person_types::type_name($type) . " ":"") . $wo["wo_ref"];
return ($full?payment_person_types::type_name($type) . " ":"") . get_customer_name($person_id);
case payment_person_types::supplier() :
return ($full?payment_person_types::type_name($type) . " ":"") . get_supplier_name($person_id);
- //case payment_person_types::Project() :
- // return ($full?payment_person_types::type_name($type) . " ":"") . get_dimension_string($person_id);
default :
//DisplayDBerror("Invalid type sent to person_name");
//return;
switch ($type)
{
case payment_person_types::misc() :
+ case payment_person_types::QuickEntry() :
case payment_person_types::WorkOrder() :
- //case payment_person_types::Project() :
return get_company_currency();
case payment_person_types::customer() :
{
case payment_person_types::misc() :
return true;
- case payment_person_types::WorkOrder() : // 070305 changed to open workorders ES
+ case payment_person_types::QuickEntry() :
+ return db_has_quick_entries();
+ case payment_person_types::WorkOrder() : // 070305 changed to open workorders JH
return db_has_open_workorders();
case payment_person_types::customer() :
return db_has_customers();
case payment_person_types::supplier() :
return db_has_suppliers();
- //case payment_person_types::Project() :
- // return db_has_dimensions();
default :
display_db_error("Invalid type sent to has_items", "");
- return;
+ return false;
}
}
}
array(
'order' => 'id',
'spec_option' => $none_option,
- 'spec_id' => 0,
+ 'spec_id' => reserved_words::get_all_numeric(),
'select_submit'=> $submit_on_change,
'async' => false,
) );
}
-function tax_groups_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
+function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
{
if ($label != null)
echo "<td>$label</td>\n";
echo "<td>";
- $str = tax_groups_list($name, $selected_id, false, $submit_on_change);
+ $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
echo "</td>\n";
return $str;
}
-function tax_groups_list_row($label, $name, $selected_id=null, $submit_on_change=false)
+function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
{
echo "<tr>\n";
- $str = tax_groups_list_cells($label, $name, $selected_id, false, $submit_on_change);
+ $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
echo "</tr>\n";
return $str;
}
return $str;
}
+//------------------------------------------------------------------------------------------------
+
+function quick_entries_list($name, $selected_id=null, $expense=true, $submit_on_change=false)
+{
+ $sql = "SELECT * FROM ".TB_PREF."quick_entries";
+ if ($expense)
+ $sql .= " WHERE deposit=0";
+ else
+ $sql .= " WHERE deposit=1";
+ combo_input($name, $selected_id, $sql, 'id', 'description',
+ array(
+ 'spec_id' => '',
+ 'order' => 'description',
+ 'select_submit'=> $submit_on_change,
+ 'async' => false
+ ) );
+
+}
+
+function quick_entries_list_row($label, $name, $selected_id=null, $expense=true, $submit_on_change=false)
+{
+ echo "<tr><td>$label</td><td>\n";
+ quick_entries_list($name, $selected_id, $expense, $submit_on_change);
+ echo "</td></tr>\n";
+}
+
+
//------------------------------------------------------------------------------------------------
function wo_types_list($name, $selected_id=null)
shippers_list_row(_("Default Shipping Company:"), 'default_ship_via', null);
-tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null, 31, 30);
+tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null);
yesno_list_row(_("Disable this Branch:"), 'disable_trans', null);
+DROP TABLE IF EXISTS `0_quick_entries`;
+
+CREATE TABLE `0_quick_entries` (
+ `id` smallint(6) NOT NULL auto_increment,
+ `description` varchar(60) NOT NULL,
+ `account` varchar(11) NOT NULL,
+ `deposit` tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `description` (`description`)
+) ENGINE=MyISAM AUTO_INCREMENT=1;
+
+INSERT INTO `0_quick_entries` VALUES ('1', 'Maintenance', '6600', '0');
+INSERT INTO `0_quick_entries` VALUES ('2', 'Phone', '6730', '0');
+INSERT INTO `0_quick_entries` VALUES ('3', 'Cash Sales', '3000', '1');
+
ALTER TABLE `0_users` ADD `print_profile` VARCHAR(30) DEFAULT '' AFTER `show_hints` ;
ALTER TABLE `0_users` ADD `rep_popup` TINYINT(1) DEFAULT '1' AFTER `print_profile` ;