createbutton.html.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * The createButton view file of doc module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Shujie Tian<tianshujie@easycorp.ltd>
  7. * @package doc
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. $createButton = $emptyCreateBtn = null;
  12. $docModel = $this->doc;
  13. $buildCreateBtn = function($typeID, $libID, $moduleID) use($lib, $docModel, $type)
  14. {
  15. global $app, $config, $lang;
  16. if($lib->type == 'custom')
  17. {
  18. $typeID = $lib->parent > 0 ? $lib->parent : $lib->id;
  19. if($lib->parent == 0) $libID = $docModel->dao->select('*')->from(TABLE_DOCLIB)->where('parent')->eq($typeID)->andWhere('deleted')->eq('0')->orderBy('id_asc')->limit(1)->fetch('id');
  20. }
  21. $buttonItems = array();
  22. foreach($lang->doc->createList as $typeKey => $typeName)
  23. {
  24. $method = 'create';
  25. $docType = zget($config->doc->iconList, $typeKey);
  26. $params = "objectType={$type}&objectID={$typeID}&libID={$libID}&moduleID={$moduleID}&type={$typeKey}";
  27. if($typeKey == 'template' && $config->edition == 'max') $params = "objectType={$type}&objectID={$typeID}&libID={$libID}&moduleID={$moduleID}&type=html";
  28. if($typeKey == 'attachment') $method = 'uploadDocs';
  29. $buttonItems[] = array
  30. (
  31. 'content' => array('html' => "<img class='mr-2' src='static/svg/{$docType}.svg'/>{$typeName}", 'class' => 'flex w-full'),
  32. 'url' => createLink('doc', $method, $params),
  33. 'data-app' => $app->tab,
  34. 'data-toggle' => strpos($this->config->doc->officeTypes, $typeKey) !== false ? 'modal' : ''
  35. );
  36. if($typeKey == 'template') $buttonItems[] = array('type' => 'divider');
  37. }
  38. return btngroup
  39. (
  40. btn
  41. (
  42. setClass('btn primary ml-2 doc-create-btn'),
  43. set::icon('plus'),
  44. set::url(createLink('doc', 'create', "objectType={$type}&objectID={$typeID}&libID={$libID}&moduleID={$moduleID}&type=html")),
  45. set('data-app', $app->tab),
  46. $lang->doc->create
  47. ),
  48. dropdown
  49. (
  50. btn(setClass('btn primary dropdown-toggle'),
  51. setStyle(array('padding' => '6px', 'border-radius' => '0 2px 2px 0'))),
  52. set::placement('bottom-end'),
  53. set::items($buttonItems)
  54. )
  55. );
  56. };
  57. $createButton = $buildCreateBtn($objectID, $libID, $moduleID);