index.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. if (cfr('CASHTYPES')) {
  3. /**
  4. * Returns default cash type setting form
  5. *
  6. * @return string
  7. */
  8. function web_CashCashtypeDefaultForm() {
  9. $defCashType = zb_StorageGet('DEF_CT');
  10. if (empty($defCashType)) {
  11. $defCashType = 'NOP';
  12. }
  13. $allCashTypes = zb_CashGetAllCashTypes();
  14. $inputs = wf_Selector('setdefaultcashtype', $allCashTypes, __('Current default cashtype for manual input'), $defCashType, true);
  15. $inputs .= wf_Submit(__('Set as default cash type'));
  16. $result = wf_Form('', 'POST', $inputs, 'glamour');
  17. return ($result);
  18. }
  19. if (isset($_GET['action'])) {
  20. // delete cash type
  21. if ($_GET['action'] == 'delete') {
  22. $cashtypeid = vf($_GET['id'], 3);
  23. //check for default cash type
  24. if ($cashtypeid != 1) {
  25. zb_CashDeleteCashtype($cashtypeid);
  26. rcms_redirect("?module=cashtypes");
  27. } else {
  28. show_error(__('You know, we really would like to let you perform this action, but our conscience does not allow us to do'));
  29. }
  30. }
  31. //cash type editing and form here
  32. if (ubRouting::get('action') == 'edit') {
  33. $cashtypeid = vf($_GET['id'], 3);
  34. if (wf_CheckPost(array('editcashtype'))) {
  35. simple_update_field('cashtype', 'cashtype', $_POST['editcashtype'], "WHERE `id`='" . $cashtypeid . "'");
  36. log_register('EDIT CASHTYPE ' . $cashtypeid);
  37. rcms_redirect("?module=cashtypes");
  38. }
  39. $cashtypename = zb_CashGetTypeName($cashtypeid);
  40. $editinputs = wf_TextInput('editcashtype', 'Cash type', $cashtypename, true, 20);
  41. $editinputs .= wf_Submit('Save');
  42. $editform = wf_Form('', 'POST', $editinputs, 'glamour');
  43. $editform .= wf_delimiter(0);
  44. $editform .= wf_BackLink('?module=cashtypes', 'Back', true);
  45. show_window(__('Edit') . ' ' . __('Cash type') . ' "' . __($cashtypename) . '"', $editform);
  46. }
  47. }
  48. //creating new cash type
  49. if (isset($_POST['newcashtype'])) {
  50. $newcashtype = mysql_real_escape_string($_POST['newcashtype']);
  51. if (!empty($newcashtype)) {
  52. zb_CashCreateCashType($newcashtype);
  53. rcms_redirect("?module=cashtypes");
  54. } else {
  55. show_error(__('No all of required fields is filled'));
  56. }
  57. }
  58. //setting default cashtype
  59. if (wf_CheckPost(array('setdefaultcashtype'))) {
  60. zb_StorageSet('DEF_CT', $_POST['setdefaultcashtype']);
  61. log_register("CASHTYPE SET DEFAULT [" . $_POST['setdefaultcashtype'] . "]");
  62. rcms_redirect("?module=cashtypes");
  63. }
  64. if (ubRouting::get('action') != 'edit') {
  65. //creation and default cash type forms here with existing cash types list
  66. $fieldname = __('Cash type');
  67. $fieldkey = 'cashtype';
  68. $formurl = '?module=cashtypes';
  69. $olddata = zb_CashGetAlltypes();
  70. $form = web_EditorTableDataFormOneField($fieldname, $fieldkey, $formurl, $olddata);
  71. show_window(__('Edit payment types'), $form);
  72. show_window(__('Default cash type'), web_CashCashtypeDefaultForm());
  73. }
  74. } else {
  75. show_error(__('You cant control this module'));
  76. }
  77. ?>