diff --git a/gulliver/bin/tasks/pakeGulliver.php b/gulliver/bin/tasks/pakeGulliver.php
index 1cd6b2b41..d5886da8f 100755
--- a/gulliver/bin/tasks/pakeGulliver.php
+++ b/gulliver/bin/tasks/pakeGulliver.php
@@ -273,8 +273,9 @@ function convertPhpName($f) {
}
function copyPluginFile($tplName, $fName, $class) {
- $pluginOutDirectory = PATH_OUTTRUNK . 'plugins' . PATH_SEP . $class . PATH_SEP . $class . PATH_SEP;
- $pluginFilename = $pluginOutDirectory . $fName;
+ $pluginOutDirectory = PATH_OUTTRUNK . "plugins" . PATH_SEP . $class . PATH_SEP;
+ $pluginFilename = $pluginOutDirectory . $fName;
+
$fileTpl = PATH_GULLIVER_HOME . 'bin' . PATH_SEP . 'tasks' . PATH_SEP . 'templates' . PATH_SEP . $tplName . '.tpl';
$content = file_get_contents($fileTpl);
$iSize = file_put_contents($pluginFilename, $content);
@@ -282,9 +283,8 @@ function copyPluginFile($tplName, $fName, $class) {
}
function savePluginFile($fName, $tplName, $class, $tableName, $fields = null) {
- $pluginOutDirectory = PATH_OUTTRUNK . 'plugins' . PATH_SEP . $class . PATH_SEP;
-
- $pluginFilename = $pluginOutDirectory . $fName;
+ $pluginOutDirectory = PATH_OUTTRUNK . "plugins" . PATH_SEP . $class . PATH_SEP;
+ $pluginFilename = $pluginOutDirectory . $fName;
$pluginTpl = PATH_GULLIVER_HOME . 'bin' . PATH_SEP . 'tasks' . PATH_SEP . 'templates' . PATH_SEP . $tplName . '.tpl';
$template = new TemplatePower($pluginTpl);
@@ -292,7 +292,7 @@ function savePluginFile($fName, $tplName, $class, $tableName, $fields = null) {
$template->assign('className', $class);
$template->assign('tableName', $tableName);
$template->assign('menuId', 'ID_' . strtoupper($class));
-
+
if( is_array($fields) ) {
foreach( $fields as $block => $data ) {
$template->gotoBlock("_ROOT");
@@ -677,6 +677,7 @@ function run_new_plugin($task, $args) {
}
}
+ //External step
$externalStep = strtolower(prompt('Create external step for Processmaker [y/N]'));
if( $externalStep == 'y' ) {
$fields['externalStep'][] = array (
@@ -690,13 +691,34 @@ function run_new_plugin($task, $args) {
savePluginFile($pluginName . PATH_SEP . "step" . $pluginName . "ApplicationAjax.php", "pluginStepApplicationAjax.php", $pluginName, $pluginName);
}
- //$dashboard = strtolower(prompt('Create an element for the Processmaker Dashboard [y/N]'));
- //if( $dashboard == 'y' ) {
- // $fields['dashboard'][] = array (
- // 'className' => $pluginName
- // );
- // savePluginFile($pluginName . PATH_SEP . 'drawChart.php', 'pluginDrawChart.php', $pluginName, $pluginName, $fields);
- //}
+ //Dashboards
+ $dashboard = strtolower(prompt("Create an element for the Processmaker Dashboards [y/N]"));
+ if ($dashboard == "y") {
+ $fields["dashboard"][] = array(
+ "className" => $pluginName
+ );
+
+ $fields["dashboardAttribute"] = "private \$dashletsUids;";
+ $fields["dashboardAttributeValue"] = "
+ \$this->dashletsUids = array(
+ array(\"DAS_UID\" => \"". G::GenerateUniqueId() ."\",
+ \"DAS_CLASS\" => \"dashlet" . $pluginName . "\",
+ \"DAS_TITLE\" => \"Dashlet $pluginName\",
+ \"DAS_DESCRIPTION\" => \"Dashlet $pluginName\",
+ \"DAS_VERSION\" => \"1.0\",
+ \"DAS_CREATE_DATE\" => date(\"Y-m-d\"),
+ \"DAS_UPDATE_DATE\" => date(\"Y-m-d\"))
+ );
+ ";
+ $fields["dashboardSetup"] = "\$this->registerDashlets();";
+ $fields["dashboardEnable"] = "\$this->dashletInsert();";
+ $fields["dashboardDisable"] = "\$this->dashletDelete();";
+
+ G::verifyPath($pluginHome . PATH_SEP . "views", true);
+
+ savePluginFile($pluginName . PATH_SEP . "classes" . PATH_SEP . "class.dashlet". $pluginName . ".php", "pluginDashletClass.php", $pluginName, $pluginName);
+ copyPluginFile("pluginDashlet.html", $pluginName . PATH_SEP . "views" . PATH_SEP . "dashlet". $pluginName . ".html", $pluginName);
+ }
//$report = strtolower(prompt('Create a Report for Processmaker [y/N]'));
//if( $report == 'y' ) {
diff --git a/gulliver/bin/tasks/templates/pluginClass.tpl b/gulliver/bin/tasks/templates/pluginClass.tpl
index d41c978a2..9ae4c015e 100755
--- a/gulliver/bin/tasks/templates/pluginClass.tpl
+++ b/gulliver/bin/tasks/templates/pluginClass.tpl
@@ -24,80 +24,6 @@
{
}
-
- //here we are defining the available charts, the dashboard setup will call this function to know the charts
- function getAvailableCharts() {
- return array(
- '{className}Chart',
- );
- }
-
- function getChart($chartName) {
- $prePath = '/sys' . SYS_SYS . '/' . SYS_LANG . '/blank/';
- $obj = new StdClass();
- switch ($chartName) {
- case '{className}Chart':
- $obj->title = '{className} Chart - Per Forum';
- break;
- }
- $obj->height = 220;
- $obj->open->image = $prePath . '{className}/drawChart?chart=' . $chartName . "&u=";
- return $obj;
- }
-
- /* definition of all charts */
- /* that definition comes in two parts :
- /* 1. the getXX() function to get the data from the databases
- /* 2. the XX() function to draw the graph
- */
-
- /** chart {className} ***/
- function get{className}Chart() {
- $dataSet = array();
- $past1months = mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"));
-
- $con = Propel::getConnection('workflow');
- $sql = "select CON_VALUE, COUNT(*) AS CANT from APPLICATION LEFT JOIN CONTENT ON ( CON_CATEGORY = 'PRO_TITLE' AND CON_ID = PRO_UID AND CON_LANG = 'en' ) GROUP BY CON_VALUE" ;
- $stmt = $con->createStatement();
- $rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
- $rs->next();
- $row = $rs->getRow();
- while (is_array($row)) {
- if (strlen(trim($row['CON_VALUE'])) > 0) {
- $label[] = $row['CON_VALUE'];
- $data[] = $row['CANT'];
- }
- $rs->next();
- $row = $rs->getRow();
- }
- $dataSet['data'] = $data;
- $dataSet['label'] = $label;
-
- $max = 1;
- foreach ($dataSet['data'] as $k => $val ) if ($val > $max) $max = $val;
- $aux = intval($max / 6) * 6 + 6;
- $dataSet['max'] = $aux;
-
- return $dataSet;
- }
-
- function {className}Chart() {
- G::LoadThirdParty("libchart/classes", "libchart" );
- $chart = new VerticalBarChart(430, 220);
- $dataSet = $this->get{className}Chart();
- $dataPostSet = new XYDataSet();
- $dataTopicSet = new XYDataSet();
- foreach ($dataSet['label'] as $key => $label) {
- $dataPostSet->addPoint(new Point($label, $dataSet['data'][$key])) ;
- }
-
- $chart->setDataSet($dataPostSet);
- $chart->setTitle( " Posts by Week " );
- $chart->render();
- }
-
-
-
//here we are defining the available charts, the dashboard setup will call this function to know the charts
diff --git a/gulliver/bin/tasks/templates/pluginDashlet.html.tpl b/gulliver/bin/tasks/templates/pluginDashlet.html.tpl
new file mode 100644
index 000000000..938acd616
--- /dev/null
+++ b/gulliver/bin/tasks/templates/pluginDashlet.html.tpl
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+ {literal}
+
+ {/literal}
+
+
+
+
+
+
+ | User name |
+ Full name |
+ Status |
+
+
+ {foreach from=$user item=item}
+
+ | {$item.userName} |
+ {$item.fullName} |
+ {$item.status} |
+
+ {/foreach}
+
+
+
+Note: {$note}
+
\ No newline at end of file
diff --git a/gulliver/bin/tasks/templates/pluginDashletClass.php.tpl b/gulliver/bin/tasks/templates/pluginDashletClass.php.tpl
new file mode 100644
index 000000000..1da71aac5
--- /dev/null
+++ b/gulliver/bin/tasks/templates/pluginDashletClass.php.tpl
@@ -0,0 +1,145 @@
+createStatement();
+
+ $arrayRole = array();
+
+ $sql = "SELECT ROL_CODE
+ FROM ROLES
+ WHERE ROL_SYSTEM = '00000000000000000000000000000002' AND ROL_STATUS = 1
+ ORDER BY ROL_CODE ASC";
+ $rsSQL = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
+ while ($rsSQL->next()) {
+ $row = $rsSQL->getRow();
+
+ $arrayRole[] = array($row["ROL_CODE"], $row["ROL_CODE"]);
+ }
+
+ ///////
+ $storeRole = new stdclass();
+ $storeRole->xtype = "arraystore";
+ $storeRole->idIndex = 0;
+ $storeRole->fields = array("value", "text");
+ $storeRole->data = $arrayRole;
+
+ ///////
+ $cboRole = new stdclass();
+ $cboRole->xtype = "combo";
+ $cboRole->name = "DAS_ROLE";
+
+ $cboRole->valueField = "value";
+ $cboRole->displayField = "text";
+ $cboRole->value = $arrayRole[0][0];
+ $cboRole->store = $storeRole;
+
+ $cboRole->triggerAction = "all";
+ $cboRole->mode = "local";
+ $cboRole->editable = false;
+
+ $cboRole->width = 320;
+ $cboRole->fieldLabel = "Role";
+ $additionalFields[] = $cboRole;
+
+ ///////
+ $txtNote = new stdclass();
+ $txtNote->xtype = "textfield";
+ $txtNote->name = "DAS_NOTE";
+ $txtNote->fieldLabel = "Note";
+ $txtNote->width = 320;
+ $txtNote->value = null;
+ $additionalFields[] = $txtNote;
+
+ ///////
+ return ($additionalFields);
+ }
+
+ public static function getXTemplate($className)
+ {
+ return "";
+ }
+
+ public function setup($config)
+ {
+ $this->role = $config["DAS_ROLE"];
+ $this->note = $config["DAS_NOTE"];
+ }
+
+ public function render($width = 300)
+ {
+ $cnn = Propel::getConnection("workflow");
+ $stmt = $cnn->createStatement();
+
+ $arrayUser = array();
+
+ $sql = "SELECT USR.USR_USERNAME, USR.USR_FIRSTNAME, USR.USR_LASTNAME, USR.USR_STATUS
+ FROM USERS AS USR
+ WHERE USR.USR_ROLE = '" . $this->role . "'
+ ORDER BY USR.USR_USERNAME ASC";
+ $rsSQL = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
+ while ($rsSQL->next()) {
+ $row = $rsSQL->getRow();
+
+ $arrayUser[] = array("userName" => $row["USR_USERNAME"], "fullName" => $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"], "status" => $row["USR_STATUS"]);
+ }
+
+ ///////
+ $dashletView = new dashlet{className}View($arrayUser, $this->note);
+ $dashletView->templatePrint();
+ }
+}
+
+
+
+
+
+class dashlet{className}View extends Smarty
+{
+ private $smarty;
+
+ private $user;
+ private $note;
+
+ public function __construct($u, $n)
+ {
+ $this->user = $u;
+ $this->note = $n;
+
+ $this->smarty = new Smarty();
+ $this->smarty->compile_dir = PATH_SMARTY_C;
+ $this->smarty->cache_dir = PATH_SMARTY_CACHE;
+ $this->smarty->config_dir = PATH_THIRDPARTY . "smarty/configs";
+ $this->smarty->caching = false;
+ $this->smarty->templateFile = PATH_PLUGINS . "{className}" . PATH_SEP . "views" . PATH_SEP . "dashlet{className}.html";
+ }
+
+ public function templateRender()
+ {
+ $this->smarty->assign("user", $this->user);
+ $this->smarty->assign("note", $this->note);
+
+ return ($this->smarty->fetch($this->smarty->templateFile));
+ }
+
+ public function templatePrint()
+ {
+ echo $this->templateRender();
+ exit(0);
+ }
+}
+?>
\ No newline at end of file
diff --git a/gulliver/bin/tasks/templates/pluginMainFile.tpl b/gulliver/bin/tasks/templates/pluginMainFile.tpl
index 4c63d19e2..533931c1b 100755
--- a/gulliver/bin/tasks/templates/pluginMainFile.tpl
+++ b/gulliver/bin/tasks/templates/pluginMainFile.tpl
@@ -3,7 +3,10 @@ G::LoadClass("plugin");
class {className}Plugin extends PMPlugin
{
- function {className}Plugin($sNamespace, $sFilename = null) {
+ {dashboardAttribute}
+
+ public function {className}Plugin($sNamespace, $sFilename = null)
+ {
$res = parent::PMPlugin($sNamespace, $sFilename);
$this->sFriendlyName = "{className} Plugin";
$this->sDescription = "Autogenerated plugin for class {className}";
@@ -13,41 +16,45 @@ class {className}Plugin extends PMPlugin
//$this->iPMVersion = 2425;
$this->aWorkspaces = null;
//$this->aWorkspaces = array("os");
+
+ {dashboardAttributeValue}
+
return $res;
}
- function setup() {
-
+ public function setup()
+ {
+
$this->setCompanyLogo("/plugin/{className}/{className}.png");
-
-
+
+
$this->registerMenu("processmaker", "menu{className}.php");
-
-
+
+
$this->registerMenu("cases", "menuCases{className}.php");
-
-
+
+
//$this->registerMenu("processmaker", "menu{className}OnTransit.php");
-
-
+
+
$this->registerStep("{GUID}", "step{className}Application", "{className} external step");
-
-
- $this->registerDashboard();
-
-
+
+
$this->registerReport();
-
-
+
+
$this->registerPmFunction();
-
-
+
+
$this->redirectLogin("PROCESSMAKER_{className}", "users/users_List");
-
+
+
+ {dashboardSetup}
}
- function install() {
-
+ public function install()
+ {
+
$RBAC = RBAC::getSingleton() ;
$RBAC->initRBAC();
$roleData = array();
@@ -60,8 +67,49 @@ class {className}Plugin extends PMPlugin
$roleData["ROL_STATUS"] = "1";
$RBAC->createRole($roleData);
$RBAC->createPermision("PM_{className}");
-
+
}
+
+ public function enable()
+ {
+ {dashboardEnable}
+ }
+
+ public function disable()
+ {
+ {dashboardDisable}
+ }
+
+
+ public function dashletInsert()
+ {
+ require_once ("classes/model/Dashlet.php");
+
+ $connection = Propel::getConnection(DashletPeer::DATABASE_NAME);
+
+ foreach ($this->dashletsUids as $dashletData) {
+ $dashlet = new Dashlet();
+
+ if (is_null($dashlet->load($dashletData["DAS_UID"]))) {
+ $dashlet->fromArray($dashletData, BasePeer::TYPE_FIELDNAME);
+ $connection->begin();
+ $dashlet->save();
+ $connection->commit();
+ }
+ }
+ }
+
+ public function dashletDelete()
+ {
+ require_once ("classes/model/Dashlet.php");
+
+ foreach ($this->dashletsUids as $dashletData) {
+ $criteria = new Criteria("workflow");
+ $criteria->add(DashletPeer::DAS_UID, $dashletData["DAS_UID"]);
+ DashletPeer::doDelete($criteria);
+ }
+ }
+
}
$oPluginRegistry = &PMPluginRegistry::getSingleton();
diff --git a/workflow/engine/classes/class.pmDashlet.php b/workflow/engine/classes/class.pmDashlet.php
index f4afef492..414201bd5 100644
--- a/workflow/engine/classes/class.pmDashlet.php
+++ b/workflow/engine/classes/class.pmDashlet.php
@@ -19,8 +19,9 @@ class PMDashlet extends DashletInstance implements DashletInterface {
$pluginsDashlets = $oPluginRegistry->getDashlets();
foreach ($pluginsDashlets as $pluginDashlet) {
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_PLUGINS . $pluginDashlet . PATH_SEP);
- require_once 'classes/class.' . $className . '.php';
}
+
+ require_once ("classes" . PATH_SEP . "class." . $className . ".php");
}
G::LoadClass($className);
eval("\$additionalFields = $className::getAdditionalFields(\$className);");
@@ -43,8 +44,9 @@ class PMDashlet extends DashletInstance implements DashletInterface {
$pluginsDashlets = $oPluginRegistry->getDashlets();
foreach ($pluginsDashlets as $pluginDashlet) {
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_PLUGINS . $pluginDashlet . PATH_SEP);
- require_once 'classes/class.' . $className . '.php';
}
+
+ require_once ("classes" . PATH_SEP . "class." . $className . ".php");
}
$this->dashletObject = new $className();
$this->dashletObject->setup($this->dashletInstance);
@@ -303,8 +305,9 @@ class PMDashlet extends DashletInstance implements DashletInterface {
$pluginsDashlets = $oPluginRegistry->getDashlets();
foreach ($pluginsDashlets as $pluginDashlet) {
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_PLUGINS . $pluginDashlet . PATH_SEP);
- require_once 'classes/class.' . $className . '.php';
}
+
+ require_once ("classes" . PATH_SEP . "class." . $className . ".php");
}
G::LoadClass($className);
eval("\$additionalFields = $className::getXTemplate(\$className);");