diff --git a/module/doc/model.php b/module/doc/model.php
index 2f626db056..5a801ce31f 100644
--- a/module/doc/model.php
+++ b/module/doc/model.php
@@ -3144,17 +3144,16 @@ class docModel extends model
* Print create document button.
*
* @param object $lib
- * @param type $type project|product|custom
- * @param int $objectID
* @param int $moduleID
* @param string $from list
* @access public
* @return string
*/
- public function printCreateBtn($lib, $type, $objectID, $moduleID, $from = '')
+ public function printCreateBtn($lib, $moduleID, $from = '')
{
if(!common::hasPriv('doc', 'create') or !isset($lib->id)) return null;
+ $objectID = zget($lib, $lib->type, 0);
$class = $from == 'list' ? 'btn-info' : 'btn-primary';
$html = "
";
$html .= html::a(helper::createLink('doc', 'create', "objectType={$lib->type}&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=html"), " {$this->lang->doc->create}", '', "class='btn $class'");
@@ -3168,7 +3167,7 @@ class docModel extends model
$attr = "data-app='{$this->app->tab}'";
$class = strpos($this->config->doc->officeTypes, $typeKey) !== false ? 'iframe' : '';
$params = "objectType={$lib->type}&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=$typeKey";
- if($typeKey == 'template') $params = "objectType=$type&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=html&from=template";
+ if($typeKey == 'template') $params = "objectType={$lib->type}&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=html&from=template";
$html .= "
";
$html .= html::a(helper::createLink('doc', 'create', $params, '', $class ? true : false), $typeName, '', "class='$class' $attr");
diff --git a/module/doc/view/doclist.html.php b/module/doc/view/doclist.html.php
index 68a57af082..f6bc1c6b85 100644
--- a/module/doc/view/doclist.html.php
+++ b/module/doc/view/doclist.html.php
@@ -35,7 +35,7 @@ body {margin-bottom: 25px;}
doc->printCreateBtn($lib, $type, $objectID, $moduleID, 'list');
+ echo $this->doc->printCreateBtn($lib, $moduleID, 'list');
}
?>
diff --git a/module/doc/view/mydoclist.html.php b/module/doc/view/mydoclist.html.php
index b551996f7e..c3072a4f3f 100644
--- a/module/doc/view/mydoclist.html.php
+++ b/module/doc/view/mydoclist.html.php
@@ -41,7 +41,7 @@ body {margin-bottom: 25px;}
doc->printCreateBtn($lib, $type, $objectID, $moduleID, 'list');
+ echo $this->doc->printCreateBtn($lib, $moduleID, 'list');
}
?>
diff --git a/module/doc/view/myspace.html.php b/module/doc/view/myspace.html.php
index 1345c8b216..e08ed4cbeb 100644
--- a/module/doc/view/myspace.html.php
+++ b/module/doc/view/myspace.html.php
@@ -41,7 +41,7 @@
echo html::a(helper::createLink('doc', 'createLib', "type=mine"), ' ' . $this->lang->doc->createLib, '', 'class="btn btn-secondary iframe" data-width="800px"');
}
- if($libID and common::hasPriv('doc', 'create')) echo $this->doc->printCreateBtn($lib, 'mine', 0, $moduleID);
+ if($libID and common::hasPriv('doc', 'create')) echo $this->doc->printCreateBtn($lib, $moduleID);
?>
diff --git a/module/doc/view/tablecontents.html.php b/module/doc/view/tablecontents.html.php
index 5efa90d57e..6167492df2 100644
--- a/module/doc/view/tablecontents.html.php
+++ b/module/doc/view/tablecontents.html.php
@@ -56,7 +56,7 @@
}
elseif($libID and common::hasPriv('doc', 'create'))
{
- echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID);
+ echo $this->doc->printCreateBtn($lib, $moduleID);
}
?>
diff --git a/module/doc/view/view.html.php b/module/doc/view/view.html.php
index a0d1d36c89..6741efc53c 100644
--- a/module/doc/view/view.html.php
+++ b/module/doc/view/view.html.php
@@ -37,7 +37,7 @@
createLink('doc', $exportMethod, "libID=$libID&moduleID=0&docID=$docID"), " " . $lang->export, 'hiddenwin', "class='btn btn-link' id='docExport'");
- if(common::hasPriv('doc', 'create')) echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID);
+ if(common::hasPriv('doc', 'create')) echo $this->doc->printCreateBtn($lib, $moduleID);
?>