index.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. if (cfr('CONTRACT')) {
  3. $alter_conf = $ubillingConfig->getAlter();
  4. if (isset($_GET['username'])) {
  5. $login = vf($_GET['username']);
  6. // change contract if need
  7. if (isset($_POST['newcontract'])) {
  8. $contract = $_POST['newcontract'];
  9. //strict unique check
  10. if ($alter_conf['STRICT_CONTRACTS_UNIQUE']) {
  11. $allcontracts = zb_UserGetAllContracts();
  12. if (isset($allcontracts[$contract])) {
  13. show_error(__('This contract is already used'));
  14. } else {
  15. zb_UserChangeContract($login, $contract);
  16. rcms_redirect("?module=contractedit&username=" . $login);
  17. }
  18. } else {
  19. zb_UserChangeContract($login, $contract);
  20. rcms_redirect("?module=contractedit&username=" . $login);
  21. }
  22. }
  23. $current_contract = zb_UserGetContract($login);
  24. $useraddress = zb_UserGetFullAddress($login) . ' (' . $login . ')';
  25. // Edit form construct
  26. $fieldnames = array('fieldname1' => __('Current contract'), 'fieldname2' => __('New contract'));
  27. $fieldkey = 'newcontract';
  28. $form = web_EditorStringDataFormContract($fieldnames, $fieldkey, $useraddress, $current_contract);
  29. show_window(__('Edit contract'), $form);
  30. //filestorage support here
  31. if (@$alter_conf['FILESTORAGE_ENABLED']) {
  32. $fileStorage = new FileStorage('USERCONTRACT', $login);
  33. show_window(__('Uploaded files'), $fileStorage->renderFilesPreview(true, ' ' . __('Upload files')));
  34. }
  35. //contract date editing
  36. $contractDates = new ContractDates();
  37. //someone creates new contractdate or changes old
  38. if (ubRouting::checkPost($contractDates::PROUTE_DATE)) {
  39. if (!empty($current_contract)) {
  40. $edContract = ubRouting::post($contractDates::PROUTE_RUNEDIT);
  41. $edContractDate = ubRouting::post($contractDates::PROUTE_DATE);
  42. $edContractFrom = ubRouting::post($contractDates::PROUTE_FROM);
  43. $edContractTill = ubRouting::post($contractDates::PROUTE_TILL);
  44. $contractDates->set($edContract, $edContractDate, $edContractFrom, $edContractTill);
  45. //back to fresh form
  46. ubRouting::nav('?module=contractedit&username=' . $login);
  47. } else {
  48. show_error(__('With this the user has not yet signed a contract'));
  49. }
  50. }
  51. //editing form
  52. show_window(__('User contract date'), $contractDates->renderChangeForm($current_contract));
  53. //agent strict assigning form
  54. if ($alter_conf['AGENTS_ASSIGN']) {
  55. if (wf_CheckPost(array('ahentsel', 'assignstrictlogin'))) {
  56. if (isset($_POST['deleteassignstrict'])) {
  57. // deletion of manual assign
  58. zb_AgentAssignStrictDelete($_POST['assignstrictlogin']);
  59. } else {
  60. //create new assign
  61. zb_AgentAssignStrictCreate($_POST['assignstrictlogin'], $_POST['ahentsel']);
  62. }
  63. rcms_redirect('?module=contractedit&username=' . $_POST['assignstrictlogin']);
  64. }
  65. $allAssignsStrict = zb_AgentAssignStrictGetAllData();
  66. show_window(__('Manual agent assign'), web_AgentAssignStrictForm($login, @$allAssignsStrict[$login]));
  67. }
  68. show_window('', web_UserControls($login));
  69. }
  70. } else {
  71. show_error(__('You cant control this module'));
  72. }