index.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. if (cfr(PseudoCRM::RIGHT_VIEW)) {
  3. $altCfg = $ubillingConfig->getAlter();
  4. if ($altCfg['PSEUDOCRM_ENABLED']) {
  5. $crm = new PseudoCRM();
  6. //some module controls
  7. $crmMainControls = $crm->renderPanel();
  8. if (!empty($crmMainControls)) {
  9. show_window('', $crmMainControls);
  10. }
  11. //rendering existing leads ajax data
  12. if (ubRouting::checkGet($crm::ROUTE_LEADS_LIST_AJ)) {
  13. $crm->ajLeadsList();
  14. }
  15. //rendering states ajax log
  16. if (ubRouting::checkGet($crm::ROUTE_REPORT_STATESLOG_AJ)) {
  17. $crm->ajStatesLog();
  18. }
  19. //new lead creation
  20. if (cfr($crm::RIGHT_LEADS)) {
  21. if (ubRouting::checkPost($crm::PROUTE_LEAD_CREATE)) {
  22. if (ubRouting::checkPost(array($crm::PROUTE_LEAD_ADDR, $crm::PROUTE_LEAD_NAME, $crm::PROUTE_LEAD_MOBILE, $crm::PROUTE_LEAD_NOTES))) {
  23. $address = ubRouting::post($crm::PROUTE_LEAD_ADDR);
  24. $realname = ubRouting::post($crm::PROUTE_LEAD_NAME);
  25. $phone = ubRouting::post($crm::PROUTE_LEAD_PHONE);
  26. $mobile = ubRouting::post($crm::PROUTE_LEAD_MOBILE);
  27. $extmobile = ubRouting::post($crm::PROUTE_LEAD_EXTMOBILE);
  28. $email = ubRouting::post($crm::PROUTE_LEAD_EMAIL);
  29. $branch = ubRouting::post($crm::PROUTE_LEAD_BRANCH);
  30. $tariff = ubRouting::post($crm::PROUTE_LEAD_TARIFF);
  31. $login = ubRouting::post($crm::PROUTE_LEAD_LOGIN);
  32. $employeeid = ubRouting::post($crm::PROUTE_LEAD_EMPLOYEE);
  33. $notes = ubRouting::post($crm::PROUTE_LEAD_NOTES);
  34. $leadCreationResult = $crm->createLead($address, $realname, $phone, $mobile, $extmobile, $email, $branch, $tariff, $login, $employeeid, $notes);
  35. ubRouting::nav($crm::URL_ME . '&' . $crm::ROUTE_LEAD_PROFILE . '=' . $leadCreationResult);
  36. } else {
  37. show_error(__('All fields marked with an asterisk are mandatory'));
  38. }
  39. }
  40. }
  41. //existing lead editing
  42. if (cfr($crm::RIGHT_LEADS)) {
  43. if (ubRouting::checkPost($crm::PROUTE_LEAD_SAVE)) {
  44. if (ubRouting::checkPost(array($crm::PROUTE_LEAD_ADDR, $crm::PROUTE_LEAD_NAME, $crm::PROUTE_LEAD_MOBILE, $crm::PROUTE_LEAD_NOTES))) {
  45. $leadId = ubRouting::post($crm::PROUTE_LEAD_SAVE);
  46. $address = ubRouting::post($crm::PROUTE_LEAD_ADDR);
  47. $realname = ubRouting::post($crm::PROUTE_LEAD_NAME);
  48. $phone = ubRouting::post($crm::PROUTE_LEAD_PHONE);
  49. $mobile = ubRouting::post($crm::PROUTE_LEAD_MOBILE);
  50. $extmobile = ubRouting::post($crm::PROUTE_LEAD_EXTMOBILE);
  51. $email = ubRouting::post($crm::PROUTE_LEAD_EMAIL);
  52. $branch = ubRouting::post($crm::PROUTE_LEAD_BRANCH);
  53. $tariff = ubRouting::post($crm::PROUTE_LEAD_TARIFF);
  54. $login = ubRouting::post($crm::PROUTE_LEAD_LOGIN);
  55. $employeeid = ubRouting::post($crm::PROUTE_LEAD_EMPLOYEE);
  56. $notes = ubRouting::post($crm::PROUTE_LEAD_NOTES);
  57. $leadSaveResult = $crm->saveLead($leadId, $address, $realname, $phone, $mobile, $extmobile, $email, $branch, $tariff, $login, $employeeid, $notes);
  58. ubRouting::nav($crm::URL_ME . '&' . $crm::ROUTE_LEAD_PROFILE . '=' . $leadSaveResult);
  59. } else {
  60. show_error(__('All fields marked with an asterisk are mandatory'));
  61. }
  62. }
  63. }
  64. //new activity creation
  65. if (cfr($crm::RIGHT_ACTIVITIES)) {
  66. if (ubRouting::checkGet($crm::ROUTE_ACTIVITY_CREATE)) {
  67. $newActivityLeadId = ubRouting::get($crm::ROUTE_ACTIVITY_CREATE);
  68. $activityCreationResult = $crm->createActivity($newActivityLeadId);
  69. //redirecting to new activity profile
  70. if ($activityCreationResult) {
  71. ubRouting::nav($crm::URL_ME . '&' . $crm::ROUTE_ACTIVITY_PROFILE . '=' . $activityCreationResult);
  72. } else {
  73. show_error(__('Something went wrong'));
  74. }
  75. }
  76. }
  77. //seting activity as done
  78. if (cfr($crm::RIGHT_ACTIVITIES)) {
  79. if (ubRouting::checkGet($crm::ROUTE_ACTIVITY_DONE)) {
  80. $actitivityId = ubRouting::get($crm::ROUTE_ACTIVITY_DONE);
  81. $crm->setActivityDone($actitivityId);
  82. ubRouting::nav($crm::URL_ME . '&' . $crm::ROUTE_ACTIVITY_PROFILE . '=' . $actitivityId);
  83. }
  84. }
  85. //seting activity as undone
  86. if (cfr($crm::RIGHT_ACTIVITIES)) {
  87. if (ubRouting::checkGet($crm::ROUTE_ACTIVITY_UNDONE)) {
  88. $actitivityId = ubRouting::get($crm::ROUTE_ACTIVITY_UNDONE);
  89. $crm->setActivityUndone($actitivityId);
  90. ubRouting::nav($crm::URL_ME . '&' . $crm::ROUTE_ACTIVITY_PROFILE . '=' . $actitivityId);
  91. }
  92. }
  93. //activity record result editing
  94. if (cfr($crm::RIGHT_ACTIVITIES)) {
  95. if (ubRouting::checkPost($crm::PROUTE_ACTIVITY_EDIT)) {
  96. $actitivityId = ubRouting::post($crm::PROUTE_ACTIVITY_EDIT);
  97. $crm->setActivityResult($actitivityId, ubRouting::post($crm::PROUTE_ACTIVITY_NOTE));
  98. ubRouting::nav($crm::URL_ME . '&' . $crm::ROUTE_ACTIVITY_PROFILE . '=' . $actitivityId);
  99. }
  100. }
  101. //rendering existing lead profile
  102. if (ubRouting::checkGet($crm::ROUTE_LEAD_PROFILE)) {
  103. $leadId = ubRouting::get($crm::ROUTE_LEAD_PROFILE, 'int');
  104. show_window(__('Lead profile') . ': ' . $crm->getLeadLabel($leadId), $crm->renderLeadProfile($leadId));
  105. //lead source and activities list here
  106. if ($crm->isLeadExists($leadId)) {
  107. show_window(__('Lead source'), $crm->renderLeadSource($leadId));
  108. show_window(__('Previous activity records'), $crm->renderLeadActivitiesList($leadId));
  109. }
  110. }
  111. //rendering existing leads list
  112. if (ubRouting::checkGet($crm::ROUTE_LEADS_LIST)) {
  113. show_window(__('Existing leads'), $crm->renderLeadsList());
  114. }
  115. //rendering existing lead activity profile
  116. if (ubRouting::checkGet($crm::ROUTE_ACTIVITY_PROFILE)) {
  117. $activityId = ubRouting::get($crm::ROUTE_ACTIVITY_PROFILE);
  118. show_window(__('Activity record'), $crm->renderActivityProfile($activityId));
  119. }
  120. //lead sources report here
  121. if (ubRouting::checkGet($crm::ROUTE_REPORT_SOURCES)) {
  122. show_window(__('Leads sources'), $crm->renderReportLeadSources());
  123. }
  124. //lead states report here
  125. if (ubRouting::checkGet($crm::ROUTE_REPORT_STATESLOG)) {
  126. show_window(__('States log'), $crm->renderReportStatesLog());
  127. }
  128. //login to lead assign
  129. if (ubRouting::checkPost(array($crm::PROUTE_LEAD_ASSIGN, $crm::PROUTE_LEAD_ASSIGN_ID))) {
  130. $assignUserLogin = ubRouting::post($crm::PROUTE_LEAD_ASSIGN);
  131. $assignLeadId = ubRouting::post($crm::PROUTE_LEAD_ASSIGN_ID);
  132. $leadAssignResult = $crm->setLeadLogin($assignLeadId, $assignUserLogin);
  133. if (empty($leadAssignResult)) {
  134. ubRouting::nav($crm::URL_ME . '&' . $crm::ROUTE_LEAD_PROFILE . '=' . $assignLeadId);
  135. } else {
  136. show_error($leadAssignResult);
  137. }
  138. }
  139. //detecting lead by assigned login
  140. if (ubRouting::checkGet($crm::ROUTE_LEAD_DETECT)) {
  141. $userLogin = ubRouting::get($crm::ROUTE_LEAD_DETECT);
  142. $detectedLeadId = $crm->searchLeadByLogin($userLogin);
  143. //go to the lead profile
  144. if ($detectedLeadId) {
  145. ubRouting::nav($crm::URL_ME . '&' . $crm::ROUTE_LEAD_PROFILE . '=' . $detectedLeadId);
  146. } else {
  147. //or render assigning form
  148. show_window(__('Assign existing lead'), $crm->renderLeadAssignForm($userLogin));
  149. //or new lead creation form
  150. if (cfr($crm::RIGHT_LEADS)) {
  151. show_window(__('Or create new lead based on this user data'), $crm->renderUserLeadCreationForm($userLogin));
  152. }
  153. //few user controls here
  154. show_window('', web_UserControls($userLogin));
  155. }
  156. }
  157. zb_BillingStats();
  158. } else {
  159. show_error(__('This module is disabled'));
  160. }
  161. } else {
  162. show_error(__('Access denied'));
  163. }