PMC-1380
This commit is contained in:
50
database/factories/FieldsFactory.php
Normal file
50
database/factories/FieldsFactory.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\Fields::class, function (Faker $faker) {
|
||||
return [
|
||||
'FLD_UID' => G::generateUniqueID(),
|
||||
'ADD_TAB_UID' => G::generateUniqueID(),
|
||||
'FLD_INDEX' => 0,
|
||||
'FLD_NAME' => 'VAR_' . $faker->sentence(1),
|
||||
'FLD_DESCRIPTION' => $faker->sentence(2),
|
||||
'FLD_TYPE' => 'VARCHAR',
|
||||
'FLD_SIZE' => 255,
|
||||
'FLD_NULL' => 1,
|
||||
'FLD_AUTO_INCREMENT' => 0,
|
||||
'FLD_KEY' => 1,
|
||||
'FLD_TABLE_INDEX' => 0,
|
||||
'FLD_FOREIGN_KEY' => 0,
|
||||
'FLD_FOREIGN_KEY_TABLE' => '',
|
||||
'FLD_DYN_NAME' => '',
|
||||
'FLD_DYN_UID' => '',
|
||||
'FLD_FILTER' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
// Create columns from a table with the foreign keys
|
||||
$factory->state(\ProcessMaker\Model\Fields::class, 'foreign_keys', function (Faker $faker) {
|
||||
return [
|
||||
'FLD_UID' => G::generateUniqueID(),
|
||||
'ADD_TAB_UID' => function() {
|
||||
$table = factory(AdditionalTables::class)->create(['ADD_TAB_OFFLINE' => 1]);
|
||||
return $table->ADD_TAB_UID;
|
||||
},
|
||||
'FLD_INDEX' => 0,
|
||||
'FLD_NAME' => 'VAR_' . $faker->sentence(1),
|
||||
'FLD_DESCRIPTION' => $faker->sentence(2),
|
||||
'FLD_TYPE' => 'VARCHAR',
|
||||
'FLD_SIZE' => 255,
|
||||
'FLD_NULL' => 1,
|
||||
'FLD_AUTO_INCREMENT' => 0,
|
||||
'FLD_KEY' => 1,
|
||||
'FLD_TABLE_INDEX' => 0,
|
||||
'FLD_FOREIGN_KEY' => 0,
|
||||
'FLD_FOREIGN_KEY_TABLE' => '',
|
||||
'FLD_DYN_NAME' => '',
|
||||
'FLD_DYN_UID' => '',
|
||||
'FLD_FILTER' => 0,
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Model\Fields;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdditionalTablesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test belongs to ADD_TAB_UID
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::columns()
|
||||
* @test
|
||||
*/
|
||||
public function it_has_a_columns_defined()
|
||||
{
|
||||
$table = factory(AdditionalTables::class)->create([
|
||||
'ADD_TAB_UID' => function () {
|
||||
return factory(Fields::class)->create()->ADD_TAB_UID;
|
||||
}
|
||||
]);
|
||||
$this->assertInstanceOf(Fields::class, $table->columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test scope query to get the offline tables
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::scopeOffline()
|
||||
* @test
|
||||
*/
|
||||
public function it_filter_offline_table()
|
||||
{
|
||||
factory(AdditionalTables::class)->create(['ADD_TAB_OFFLINE' => 0]);
|
||||
$table = factory(AdditionalTables::class)->create([
|
||||
'ADD_TAB_OFFLINE' => 1
|
||||
]);
|
||||
$this->assertCount(1, $table->offline([$table->ADD_TAB_OFFLINE])->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get the structure of offline tables
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::getTablesOfflineStructure()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_structure_from_offline_tables()
|
||||
{
|
||||
factory(Fields::class)->states('foreign_keys')->create();
|
||||
$results = AdditionalTables::getTablesOfflineStructure();
|
||||
$this->assertNotEmpty($results);
|
||||
foreach ($results as $row) {
|
||||
$this->assertArrayHasKey('add_tab_uid', $row);
|
||||
$this->assertArrayHasKey('add_tab_name', $row);
|
||||
$this->assertArrayHasKey('add_tab_description', $row);
|
||||
$this->assertArrayHasKey('add_tab_class_name', $row);
|
||||
$this->assertArrayHasKey('fields', $row);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get the data of offline tables
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AdditionalTables::getTablesOfflineData()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_data_from_offline_tables()
|
||||
{
|
||||
factory(Fields::class)->states('foreign_keys')->create();
|
||||
$results = AdditionalTables::getTablesOfflineData();
|
||||
$this->assertNotEmpty($results);
|
||||
foreach ($results as $row) {
|
||||
$this->assertArrayHasKey('add_tab_uid', $row);
|
||||
$this->assertArrayHasKey('add_tab_name', $row);
|
||||
$this->assertArrayHasKey('add_tab_description', $row);
|
||||
$this->assertArrayHasKey('add_tab_class_name', $row);
|
||||
$this->assertArrayHasKey('rows', $row);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Model\Fields;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FieldsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test belongs to ADD_TAB_UID
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Fields::table()
|
||||
* @test
|
||||
*/
|
||||
public function it_has_a_columns_defined()
|
||||
{
|
||||
$tableColumns = factory(Fields::class)->create([
|
||||
'ADD_TAB_UID' => function () {
|
||||
return factory(AdditionalTables::class)->create()->ADD_TAB_UID;
|
||||
}
|
||||
]);
|
||||
$this->assertInstanceOf(AdditionalTables::class, $tableColumns->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test scope and the query with a specific ADD_TAB_UID
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Fields::scopeTable()
|
||||
* @covers \ProcessMaker\Model\Fields::getFields()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_fields_from_specific_table()
|
||||
{
|
||||
$fields = factory(Fields::class)->create();
|
||||
$result = Fields::getFields($fields->ADD_TAB_UID);
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ class Table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTables($pro_uid = '', $reportFlag = false)
|
||||
public function getTables($pro_uid = '', $reportFlag = false, $offline = false)
|
||||
{
|
||||
//VALIDATION
|
||||
if ($reportFlag) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use AdditionalTables as ModelAdditionalTables;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AdditionalTables extends Model
|
||||
@@ -9,4 +10,84 @@ class AdditionalTables extends Model
|
||||
protected $table = 'ADDITIONAL_TABLES';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the fields related to the table belongs to
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return $this->belongsTo(Fields::class, 'ADD_TAB_UID', 'ADD_TAB_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the offline tables
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeOffline($query)
|
||||
{
|
||||
return $query->where('ADD_TAB_OFFLINE', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the structure of offline tables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTablesOfflineStructure()
|
||||
{
|
||||
$query = AdditionalTables::query()->select([
|
||||
'ADD_TAB_UID',
|
||||
'ADD_TAB_NAME',
|
||||
'ADD_TAB_DESCRIPTION',
|
||||
'ADD_TAB_CLASS_NAME'
|
||||
]);
|
||||
$query->offline();
|
||||
|
||||
$results = $query->get();
|
||||
$data = [];
|
||||
$results->each(function ($item, $key) use (&$data) {
|
||||
$data[$key] = array_change_key_case($item->toArray(), CASE_LOWER);
|
||||
$data[$key]['fields'] = Fields::getFields($item->ADD_TAB_UID);
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data of offline tables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTablesOfflineData()
|
||||
{
|
||||
$query = AdditionalTables::query()->select([
|
||||
'ADD_TAB_UID',
|
||||
'ADD_TAB_NAME',
|
||||
'ADD_TAB_DESCRIPTION',
|
||||
'ADD_TAB_CLASS_NAME'
|
||||
]);
|
||||
$query->offline();
|
||||
|
||||
$results = $query->get();
|
||||
$data = [];
|
||||
$results->each(function ($item, $key) use (&$data) {
|
||||
$data[$key] = array_change_key_case($item->toArray(), CASE_LOWER);
|
||||
|
||||
$additionalTables = new ModelAdditionalTables();
|
||||
$result = $additionalTables->getAllData($item->ADD_TAB_UID);
|
||||
if (empty($result['rows'])) {
|
||||
$data[$key]['rows'] = [];
|
||||
} else {
|
||||
foreach ($result['rows'] as $i => $row) {
|
||||
$data[$key]['rows'][$i] = $row;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
55
workflow/engine/src/ProcessMaker/Model/Fields.php
Normal file
55
workflow/engine/src/ProcessMaker/Model/Fields.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fields extends Model
|
||||
{
|
||||
protected $table = 'FIELDS';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the fields related to the table belongs to
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function table()
|
||||
{
|
||||
return $this->belongsTo(AdditionalTables::class, 'ADD_TAB_UID', 'ADD_TAB_UID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the offline tables
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param string $tabUid
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeTable($query, $tabUid)
|
||||
{
|
||||
return $query->where('ADD_TAB_UID', '=', $tabUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offline tables
|
||||
*
|
||||
* @param string $tabUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFields($tabUid)
|
||||
{
|
||||
$query = Fields::query();
|
||||
$query->table($tabUid);
|
||||
|
||||
$results = $query->get();
|
||||
$data = [];
|
||||
$results->each(function ($item, $key) use (&$data) {
|
||||
$data[$key] = array_change_key_case($item->toArray(), CASE_LOWER);
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Exception;
|
||||
use Luracast\Restler\RestException;
|
||||
use ProcessMaker\BusinessModel\Table as BusinessModelTable;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
use ProcessMaker\Services\Api;
|
||||
|
||||
/**
|
||||
@@ -14,85 +16,137 @@ use ProcessMaker\Services\Api;
|
||||
class Pmtable extends Api
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
* Get a list of the PM tables in the workspace. It does not include any Report Table
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @url GET
|
||||
* @status 200
|
||||
*
|
||||
* @param boolean $offline {@from path}
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url GET
|
||||
* @link https://wiki.processmaker.com/3.1/REST_API_Administration/PM_Tables#PM_Tables_List:_GET_.2Fpmtable
|
||||
*/
|
||||
public function doGetPmTables()
|
||||
public function doGetPmTables($offline = false)
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$response = $oPmTable->getTables();
|
||||
if ($offline) {
|
||||
$response = AdditionalTables::getTablesOfflineStructure();
|
||||
} else {
|
||||
$pmTable = new BusinessModelTable();
|
||||
$response = $pmTable->getTables();
|
||||
}
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* Get the data of the offline PM tables
|
||||
*
|
||||
* @url GET /offline/data
|
||||
* @status 200
|
||||
*
|
||||
* @param boolean $compress {@from path}
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @link https://wiki.processmaker.com/3.1/REST_API_Administration/PM_Tables#PM_Tables_List:_GET_.2Fpmtable
|
||||
*/
|
||||
public function doGetPmTablesDataOffline($compress = true)
|
||||
{
|
||||
try {
|
||||
$data = AdditionalTables::getTablesOfflineData();
|
||||
if ($compress) {
|
||||
$json = json_encode($data);
|
||||
$compressed = gzcompress($json, 5);
|
||||
echo $compressed;
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the structure from a specific PM Table, including a list of its fields and their properties.
|
||||
*
|
||||
* @url GET /:pmt_uid
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @link https://wiki.processmaker.com/3.1/REST_API_Administration/PM_Tables#Get_PM_Table_Structure:_GET_.2Fpmtable.2F.7Bpmt_uid.7D
|
||||
*/
|
||||
public function doGetPmTable($pmt_uid)
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oPmTable = new BusinessModelTable();
|
||||
$response = $oPmTable->getTable($pmt_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data from a PM table
|
||||
*
|
||||
* @url GET /:pmt_uid/data
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param string $filter
|
||||
* @param string $q
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url GET /:pmt_uid/data
|
||||
*
|
||||
*/
|
||||
public function doGetPmTableData($pmt_uid, $filter = null, $q = "")
|
||||
{
|
||||
try {
|
||||
$oPmTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oPmTable = new BusinessModelTable();
|
||||
$response = $oPmTable->getTableData($pmt_uid, null, $filter, false, $q);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PM Table
|
||||
*
|
||||
* @url POST
|
||||
* @status 201
|
||||
*
|
||||
* @param array $request_data
|
||||
* @param string $pmt_tab_name {@from body}
|
||||
* @param string $pmt_tab_dsc {@from body}
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url POST
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostPmTable(
|
||||
$request_data,
|
||||
@@ -100,58 +154,58 @@ class Pmtable extends Api
|
||||
$pmt_tab_dsc = ''
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->saveTable($request_data);
|
||||
if (isset($response['pro_uid'])) {
|
||||
unset($response['pro_uid']);
|
||||
}
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* Add a new record to a PM Table
|
||||
*
|
||||
* @param array $request_data
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url POST /:pmt_uid/data
|
||||
* @status 201
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
*/
|
||||
public function doPostPmTableData(
|
||||
$pmt_uid,
|
||||
$request_data
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->saveTableData($pmt_uid, $request_data);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update pm-table.
|
||||
* Update the structure of a PM table.
|
||||
*
|
||||
* @url PUT /:pmt_uid
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
*
|
||||
* @return void
|
||||
* @throw RestException
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @throws RestException
|
||||
*/
|
||||
public function doPutPmTable(
|
||||
$pmt_uid,
|
||||
@@ -167,9 +221,10 @@ class Pmtable extends Api
|
||||
}
|
||||
|
||||
/**
|
||||
* Update pm-table data.
|
||||
* Update the data of an existing record in a PM table.
|
||||
*
|
||||
* @url PUT /:pmt_uid/data
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param array $request_data
|
||||
@@ -185,37 +240,47 @@ class Pmtable extends Api
|
||||
$request_data
|
||||
) {
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->updateTableData($pmt_uid, $request_data);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specified PM table and all its data.
|
||||
*
|
||||
* @url DELETE /:pmt_uid
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url DELETE /:pmt_uid
|
||||
*/
|
||||
public function doDeletePmTable($pmt_uid)
|
||||
{
|
||||
try {
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->deleteTable($pmt_uid);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a record from a PM table, by specifying its primary key(s). The PM Table can have up to 3 primary key
|
||||
* fields.
|
||||
*
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2/:key3/:value3
|
||||
* @status 200
|
||||
*
|
||||
* @param string $pmt_uid {@min 1} {@max 32}
|
||||
* @param string $key1 {@min 1}
|
||||
* @param string $value1 {@min 1}
|
||||
@@ -225,15 +290,10 @@ class Pmtable extends Api
|
||||
* @param string $value3
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2
|
||||
* @url DELETE /:pmt_uid/data/:key1/:value1/:key2/:value2/:key3/:value3
|
||||
*/
|
||||
public function doDeletePmTableData($pmt_uid, $key1, $value1, $key2 = '', $value2 = '', $key3 = '', $value3 = '')
|
||||
{
|
||||
@@ -245,10 +305,10 @@ class Pmtable extends Api
|
||||
if ($key3 != '') {
|
||||
$rows[$key3] = $value3;
|
||||
}
|
||||
$oReportTable = new \ProcessMaker\BusinessModel\Table();
|
||||
$oReportTable = new BusinessModelTable();
|
||||
$response = $oReportTable->deleteTableData($pmt_uid, $rows);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* PM tables Edit
|
||||
* @author Erik A. O. <erik@colosa.com>
|
||||
*/
|
||||
|
||||
var store;
|
||||
@@ -99,14 +98,13 @@ Ext.onReady(function () {
|
||||
listeners: {rowdblclick: AssignFieldsAction}
|
||||
});
|
||||
|
||||
//selecion model for table columns grid
|
||||
//selection model for table columns grid
|
||||
sm = new Ext.grid.RowSelectionModel({
|
||||
selectSingle: false,
|
||||
listeners: {
|
||||
selectionchange: function (sm) {
|
||||
switch (sm.getCount()) {
|
||||
case 0:
|
||||
//Ext.getCmp('removeButton').disable();
|
||||
Ext.getCmp('editColumn').disable();
|
||||
Ext.getCmp('removeColumn').disable();
|
||||
break;
|
||||
@@ -115,7 +113,6 @@ Ext.onReady(function () {
|
||||
Ext.getCmp('removeColumn').enable();
|
||||
break;
|
||||
default:
|
||||
//Ext.getCmp('removeButton').enable();
|
||||
Ext.getCmp('editColumn').disable();
|
||||
Ext.getCmp('removeColumn').enable();
|
||||
break;
|
||||
@@ -196,7 +193,6 @@ Ext.onReady(function () {
|
||||
if (valueInputField) {
|
||||
this.setValue(this.getValue().replace(/\s/g, '').toUpperCase());
|
||||
} else {
|
||||
//Ext.Msg.alert(_('ID_WARNING'), _('ID_FIELD_NAME'));
|
||||
this.setValue('');
|
||||
}
|
||||
}
|
||||
@@ -232,7 +228,7 @@ Ext.onReady(function () {
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}, {
|
||||
id: 'field_type',
|
||||
@@ -286,7 +282,7 @@ Ext.onReady(function () {
|
||||
|
||||
flagShowMessageError = 1;
|
||||
}
|
||||
}//select
|
||||
}
|
||||
}
|
||||
})
|
||||
}, {
|
||||
@@ -481,7 +477,6 @@ Ext.onReady(function () {
|
||||
|
||||
//table columns grid
|
||||
assignedGrid = new Ext.grid.GridPanel({
|
||||
//title: 'Columns',
|
||||
region: 'center',
|
||||
id: 'assignedGrid',
|
||||
ddGroup: 'availableGridDDGroup',
|
||||
@@ -553,7 +548,6 @@ Ext.onReady(function () {
|
||||
});
|
||||
|
||||
assignedGrid.getSelectionModel().on('selectionchange', function (sm) {
|
||||
//alert('s');
|
||||
});
|
||||
|
||||
// (vertical) selection buttons
|
||||
@@ -588,9 +582,7 @@ Ext.onReady(function () {
|
||||
|
||||
|
||||
FieldsPanel = new Ext.Panel({
|
||||
//title: _('ID_FIELDS'),
|
||||
region: 'center',
|
||||
//autoWidth : true,
|
||||
width: 150,
|
||||
layout: 'hbox',
|
||||
defaults: {flex: 1}, //auto stretch
|
||||
@@ -702,7 +694,6 @@ Ext.onReady(function () {
|
||||
fieldLabel: _("ID_DB_CONNECTION"),
|
||||
hiddenName: 'DBS_UID',
|
||||
store: dbConnectionsStore,
|
||||
//value: 'rp',
|
||||
valueField: 'DBS_UID',
|
||||
displayField: 'DBS_NAME',
|
||||
triggerAction: 'all',
|
||||
@@ -765,8 +756,6 @@ Ext.onReady(function () {
|
||||
]
|
||||
});
|
||||
|
||||
//items.push(comboDbConnections);
|
||||
|
||||
var frmDetails = new Ext.FormPanel({
|
||||
id: 'frmDetails',
|
||||
region: 'north',
|
||||
@@ -777,7 +766,6 @@ Ext.onReady(function () {
|
||||
frame: true,
|
||||
height: 170,
|
||||
items: items,
|
||||
//tbar : tbar,
|
||||
waitMsgTarget: true,
|
||||
defaults: {
|
||||
allowBlank: false,
|
||||
@@ -786,7 +774,6 @@ Ext.onReady(function () {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
southPanel = new Ext.FormPanel({
|
||||
region: 'south',
|
||||
buttons: [
|
||||
@@ -849,7 +836,6 @@ Ext.onReady(function () {
|
||||
});
|
||||
|
||||
// actions
|
||||
|
||||
function createReportTable()
|
||||
{
|
||||
var tableName = Ext.getCmp('REP_TAB_NAME').getValue().trim();
|
||||
@@ -1006,7 +992,6 @@ function _showDebugWin(content)
|
||||
modal: false,
|
||||
autoScroll: true,
|
||||
maximizable: true,
|
||||
//closeAction: 'hide',
|
||||
maximizable: false,
|
||||
items: [],
|
||||
x: 0,
|
||||
@@ -1019,7 +1004,6 @@ function _showDebugWin(content)
|
||||
|
||||
function addColumn() {
|
||||
var PMRow = assignedGrid.getStore().recordType;
|
||||
//var meta = mapPMFieldType(records[i].data['FIELD_UID']);
|
||||
var row = new PMRow({
|
||||
uid: '',
|
||||
field_uid: '',
|
||||
@@ -1164,7 +1148,7 @@ function editorFieldsEnableDisable(fieldTypeValue, fieldNull, fieldPrimaryKey, f
|
||||
}
|
||||
}
|
||||
|
||||
////ASSIGNBUTON FUNCTIONALITY
|
||||
//Assign button functionality
|
||||
AssignFieldsAction = function () {
|
||||
var records, i;
|
||||
|
||||
@@ -1306,7 +1290,6 @@ var DDLoadFields = function () {
|
||||
|
||||
//add on target grid
|
||||
for (i = 0; i < records.length; i++) {
|
||||
//arrAux[r] = records[r].data['FIELD_UID'];
|
||||
var meta = mapPMFieldType(records[i].data['FIELD_UID']);
|
||||
var row = new PMRow({
|
||||
uid: '',
|
||||
@@ -1329,7 +1312,6 @@ var DDLoadFields = function () {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
//sw_func_groups = true;
|
||||
};
|
||||
|
||||
function loadTableRowsFromArray(records)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* PM tables list
|
||||
*/
|
||||
|
||||
var newButton;
|
||||
var editButton;
|
||||
var deleteButton;
|
||||
@@ -20,7 +24,7 @@ var currentSelectedRow = -1;
|
||||
var extensionPmt = 'pmt';
|
||||
|
||||
Ext.onReady(function () {
|
||||
///Keyboard Events
|
||||
// Keyboard Events
|
||||
new Ext.KeyMap(document, {
|
||||
key: Ext.EventObject.F5,
|
||||
fn: function (keycode, e) {
|
||||
@@ -62,13 +66,6 @@ Ext.onReady(function () {
|
||||
|
||||
var flagProcessmap = (typeof ('flagProcessmap') != 'undefined') ? flagProcessmap : 0;
|
||||
|
||||
/*if (PRO_UID !== false) {
|
||||
newMenuOptions.push({
|
||||
text: _('ID_NEW_REPORT_TABLE_OLD'),
|
||||
handler: NewReportTableOld
|
||||
});
|
||||
}*/
|
||||
|
||||
if (PRO_UID !== false) {
|
||||
newButton = new Ext.Action({
|
||||
id: 'newButton',
|
||||
@@ -424,14 +421,14 @@ Ext.onReady(function () {
|
||||
infoGrid.store.load();
|
||||
});
|
||||
|
||||
//Funtion Handles Context Menu Opening
|
||||
//Function Handles Context Menu Opening
|
||||
onMessageContextMenu = function (grid, rowIndex, e) {
|
||||
e.stopEvent();
|
||||
var coords = e.getXY();
|
||||
contextMenu.showAt([coords[0], coords[1]]);
|
||||
};
|
||||
|
||||
/////JS FUNCTIONS
|
||||
// JS Functions
|
||||
|
||||
//Capitalize String Function
|
||||
capitalize = function (s) {
|
||||
@@ -454,9 +451,6 @@ NewReportTable = function () {
|
||||
};
|
||||
|
||||
NewReportTableOld = function () {
|
||||
//location.href = 'reportTables/edit?PRO_UID='+PRO_UID+'&tableType=report';
|
||||
//parent.reportTables2();
|
||||
//parent.Pm.data.render.buildingBlocks.injector('reportTables2');
|
||||
location.href = 'reportTables/reportTables_Edit?PRO_UID=' + PRO_UID;
|
||||
};
|
||||
|
||||
@@ -544,7 +538,6 @@ ImportPMTable = function () {
|
||||
resizable: false,
|
||||
items: [
|
||||
new Ext.FormPanel({
|
||||
/*renderTo: 'form-panel',*/
|
||||
id: 'uploader',
|
||||
fileUpload: true,
|
||||
width: 400,
|
||||
@@ -604,7 +597,6 @@ ImportPMTable = function () {
|
||||
plain: true,
|
||||
html: '<h3>' + _('ID_IMPORTING_ERROR') + '</h3>' + result.message,
|
||||
items: [],
|
||||
|
||||
buttons: [{
|
||||
text: 'Close',
|
||||
handler: function () {
|
||||
@@ -700,7 +692,6 @@ PMTableData = function ()
|
||||
var row = Ext.getCmp('infoGrid').getSelectionModel().getSelected();
|
||||
var type = row.get('PRO_UID');
|
||||
|
||||
//location.href = 'pmTables/data?id='+row.get('ADD_TAB_UID');
|
||||
if (row.get('TYPE') != '') {
|
||||
PMExt.info(_('ID_INFO'), _('ID_DATA_LIST_NOT_AVAILABLE_FOR_OLDVER'));
|
||||
return;
|
||||
@@ -715,7 +706,6 @@ PMTableData = function ()
|
||||
modal: true,
|
||||
maximizable: true,
|
||||
constrain: true,
|
||||
//closeAction:'hide',
|
||||
plain: true,
|
||||
items: [{
|
||||
xtype: "iframepanel",
|
||||
|
||||
Reference in New Issue
Block a user