You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

256 lines
8.4 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <?php
  2. require_once("redmine.php");
  3. $obj_redmine = new class_bitrix_to_redmine();
  4. $test_contact = array("contact" => array("first_name" => "Test testing",
  5. "project_id" => "managers",
  6. "is_company" => false,
  7. "phone" => "+79997994838",
  8. "email" => "mvg@a-real.ru"
  9. )
  10. );
  11. // для получения данных тикета:
  12. $include[]= "relations";
  13. $include[]= "journals";
  14. $res = $obj_redmine->get_issue($issue_id="11380", $project_id = "", $inc=$include);
  15. // var_dump($res);
  16. // вернется массив, первым элементом которого будет http ответ, 200 в случае успеха, ну или другой какой, если что-то пошло не так
  17. // вторым элементом - json со всеми доступными и заполненными полями.
  18. /* array(2) {
  19. * [0]=> int(200) - код ответа
  20. * [1]=> - все возможные поля, с типами
  21. * object(stdClass)#14 (1) {
  22. * ["issue"]=> object(stdClass)#2 (20) {
  23. * ["id"]=> int(11380)
  24. * ["project"]=> object(stdClass)#3 (2) {
  25. * ["id"]=> int(14)
  26. * ["name"]=> string(45) "Пользовательские тикеты"
  27. * }
  28. * ["tracker"]=> object(stdClass)#4 (2) {
  29. * ["id"]=> int(3)
  30. * ["name"]=> string(18) "Поддержка"
  31. * }
  32. * ["status"]=> object(stdClass)#5 (2) {
  33. * ["id"]=> int(5)
  34. * ["name"]=> string(14) "Закрыта"
  35. * }
  36. * ["priority"]=> object(stdClass)#6 (2) {
  37. * ["id"]=> int(2)
  38. * ["name"]=> string(20) "Нормальный"
  39. * }
  40. * ["author"]=> object(stdClass)#7 (2) {
  41. * ["id"]=> int(277)
  42. * ["name"]=> string(31) "Михаил Гребенкин"
  43. * }
  44. * ["assigned_to"]=> object(stdClass)#8 (2) {
  45. * ["id"]=> int(7)
  46. * ["name"]=> string(7) "Support"
  47. * }
  48. * ["subject"]=> string(13) "One more test"
  49. * ["description"]=> string(18) "test test one more"
  50. * ["start_date"]=> NULL
  51. * ["due_date"]=> NULL
  52. * ["done_ratio"]=> int(0)
  53. * ["is_private"]=> bool(true)
  54. * ["estimated_hours"]=> NULL
  55. * ["total_estimated_hours"]=> NULL
  56. * ["custom_fields"]=> array(2) {
  57. * [0]=> object(stdClass)#9 (3) {
  58. * ["id"]=> int(32)
  59. * ["name"]=> string(16) "Версия ICS"
  60. * ["value"]=> string(5) "7.0.1"
  61. * }
  62. * [1]=> object(stdClass)#10 (3) {
  63. * ["id"]=> int(33)
  64. * ["name"]=> string(21) "Тип клиента"
  65. * ["value"]=> string(0) ""
  66. * }
  67. * }
  68. * ["created_on"]=> string(20) "2020-08-18T13:34:33Z"
  69. * ["updated_on"]=> string(20) "2020-08-19T05:09:53Z"
  70. * ["closed_on"]=> string(20) "2020-08-19T05:09:53Z"
  71. * ["journals"]=> array(1) { - тут отображаются все комментарии к задачам
  72. * [0]=> object(stdClass)#11 (6) {
  73. * ["id"]=> int(43939)
  74. * ["user"]=> object(stdClass)#12 (2) {
  75. * ["id"]=> int(56)
  76. * ["name"]=> string(29) "Дарья Канцырева"
  77. * }
  78. * ["notes"]=> NULL
  79. * ["created_on"]=> string(20) "2020-08-19T05:09:53Z"
  80. * ["private_notes"]=> bool(false)
  81. * ["details"]=> array(1) {
  82. * [0]=> object(stdClass)#13 (4) {
  83. * ["property"]=> string(4) "attr"
  84. * ["name"]=> string(9) "status_id"
  85. * ["old_value"]=> string(1) "1"
  86. * ["new_value"]=> string(1) "5"
  87. * }
  88. * }
  89. * }
  90. * }
  91. * }
  92. * }
  93. *}
  94. */
  95. $res = $obj_redmine->get_contact_id("3373", true);
  96. // var_dump($res);
  97. /*
  98. [0]=> int(200)
  99. [1]=> object(stdClass)#32 (1) {
  100. ["contact"]=> object(stdClass)#15 (20) {
  101. ["id"]=> int(3373)
  102. ["is_company"]=> bool(false)
  103. ["first_name"]=> string(15) "Wasiliy Besedin"
  104. ["last_name"]=> NULL
  105. ["middle_name"]=> NULL
  106. ["company"]=> NULL
  107. ["website"]=> NULL
  108. ["skype_name"]=> NULL
  109. ["birthday"]=> NULL
  110. ["job_title"]=> NULL
  111. ["background"]=> NULL
  112. ["address"]=> object(stdClass)#16 (6) {
  113. ["full_address"]=> NULL
  114. ["street"]=> NULL
  115. ["city"]=> NULL
  116. ["region"]=> NULL
  117. ["country"]=> NULL
  118. ["postcode"]=> NULL
  119. }
  120. ["phones"]=> array(1) {
  121. [0]=> object(stdClass)#17 (1) {
  122. ["number"]=> string(12) "+79066352453"
  123. }
  124. }
  125. ["emails"]=> array(1) {
  126. [0]=> object(stdClass)#18 (1) {
  127. ["address"]=> string(16) "besco@yabesco.ru"
  128. }
  129. }
  130. ["tag_list"]=> array(0) {
  131. }
  132. ["custom_fields"]=> array(9) {
  133. [0]=> object(stdClass)#19 (3) {
  134. ["id"]=> int(5)
  135. ["name"]=> string(6) "ИНН"
  136. ["value"]=> string(10) "7655546378"
  137. }
  138. [1]=> object(stdClass)#20 (3) {
  139. ["id"]=> int(10)
  140. ["name"]=> string(27) "Номер договора"
  141. ["value"]=> string(0) ""
  142. }
  143. [2]=> object(stdClass)#21 (3) {
  144. ["id"]=> int(11)
  145. ["name"]=> string(16) "Лицензия"
  146. ["value"]=> string(0) ""
  147. }
  148. [3]=> object(stdClass)#22 (3) {
  149. ["id"]=> int(6)
  150. ["name"]=> string(31) "Статус поддержки"
  151. ["value"]=> string(0) ""
  152. }
  153. [4]=> object(stdClass)#23 (3) {
  154. ["id"]=> int(12)
  155. ["name"]=> string(26) "Логин на сайте"
  156. ["value"]=> string(0) ""
  157. }
  158. [5]=> object(stdClass)#24 (3) {
  159. ["id"]=> int(13)
  160. ["name"]=> string(21) "Внешний код"
  161. ["value"]=> string(0) ""
  162. }
  163. [6]=> object(stdClass)#25 (3) {
  164. ["id"]=> int(14)
  165. ["name"]=> string(30) "Лицензия. Начало"
  166. ["value"]=> string(0) ""
  167. }
  168. [7]=> object(stdClass)#26 (3) {
  169. ["id"]=> int(15)
  170. ["name"]=> string(28) "Лицензия. Финал"
  171. ["value"]=> string(0) ""
  172. }
  173. [8]=> object(stdClass)#27 (3) {
  174. ["id"]=> int(16)
  175. ["name"]=> string(5) "UF_IP"
  176. ["value"]=> string(0) ""
  177. }
  178. }
  179. ["created_on"]=> string(20) "2020-02-24T21:27:02Z"
  180. ["updated_on"]=> string(20) "2020-02-24T21:27:02Z"
  181. ["projects"]=> array(2) {
  182. [0]=> object(stdClass)#28 (2) {
  183. ["id"]=> int(17)
  184. ["name"]=> string(8) "Managers"
  185. }
  186. [1]=> object(stdClass)#29 (2) {
  187. ["id"]=> int(14)
  188. ["name"]=> string(45) "Пользовательские тикеты"
  189. }
  190. }
  191. ["issues"]=> array(1) { // список задач, привязанных к контакту
  192. [0]=> object(stdClass)#30 (6) {
  193. ["id"]=> int(10442)
  194. ["subject"]=> string(21) "testing testing again"
  195. ["status"]=> object(stdClass)#31 (2) {
  196. ["id"]=> int(5)
  197. ["name"]=> string(14) "Закрыта"
  198. }
  199. ["due_date"]=> NULL
  200. ["created_on"]=> string(20) "2020-06-26T15:17:02Z"
  201. ["updated_on"]=> string(20) "2020-06-29T12:24:50Z"
  202. }
  203. }
  204. }
  205. }
  206. }
  207. */
  208. // для создания тикета create_ticket()
  209. // поиск контакта - только по e-mail клиента (текущего контакта)
  210. $res = $obj_redmine->create_ticket("besco@yabesco.ru", "One more test", "test test one more");
  211. // var_dump($res);
  212. /*
  213. }
  214. [0]=> int(201) - код возврата. 201 - успех
  215. [1]=> NULL
  216. }
  217. */
  218. // работа с вложениями
  219. // закачать вложение, получив обратно токен
  220. // $filecontent = file_get_contents("screenshot.png");
  221. // $token = $obj_redmine->get_upload_token($filecontent);
  222. //$token = $token->upload->token;
  223. //var_dump($token);
  224. // закачать вложение, сразу прикрепить к issue (тикет)
  225. //$filecontent = file_get_contents("screenshot.png");
  226. // $res = $obj_redmine->upload_attachment('10314', 'screenshot.png', 'image/png', $filecontent);
  227. // var_dump($res);
  228. // получить issue с журналом и вложениями
  229. // $inc = array( 0 => "journals",
  230. // 1 => "attachments"
  231. // );
  232. //$res = $obj_redmine->get_issue('10314', '', $inc);
  233. //var_dump($res);
  234. // получить прикрепленное вложение
  235. // $thumbnail - если true, то выкачается эскиз.
  236. // $res = $obj_redmine->download_attachment('5152', true);
  237. //file_put_contents('screenshot_eskiz.png', $res);
  238. ?>

Powered by TurnKey Linux.