- Thu Sep 06, 2012 12:04 pm
#25454
I'm not an advance php developer but I manage to add an item to the menu section in supervisor options. What i want to do is to put a section where que supervisor can see what cases hasn´t been notified yet about the resolution, but when i add an extra condition or filter it shows nothing, i'll try to explain it as best as i can.
Basically i copied the code for review option (to_revise) in workflow/engine/classes/model/AppCacheView.php and change the name to "getNoNotificado".
In workflow\engine\methods\cases\casesListExtJs.php i olso copied the code of "to_revise".
I know it wouldn't magically work just like that, so i kept investigating and i found some more code to try.
In workflow\engine\classes\model\om\BaseAppCacheViewPeer.php added
Basically i copied the code for review option (to_revise) in workflow/engine/classes/model/AppCacheView.php and change the name to "getNoNotificado".
Code: Select all
function getListCounters ( $type, $userUid, $processSummary ) {
switch ( $type ) {
...
case 'no_notificado' :
$Criteria = $this->getNoNotificadoCountCriteria( $userUid );
break;
...
}
return AppCacheViewPeer::doCount($Criteria);
}
Code: Select all
function getNoNotificado ( $userUid, $doCount ) {
require_once 'classes/model/ProcessUser.php';
// adding configuration fields from the configuration options
// and forming the criteria object
$oCriteria = new Criteria('workflow');
$oCriteria->add(ProcessUserPeer::USR_UID, $userUid );
$oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
$oDataset = ProcessUserPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aProcesses = array();
while ($aRow = $oDataset->getRow()) {
$aProcesses[] = $aRow['PRO_UID'];
$oDataset->next();
}
if ( $doCount && !isset($this->confCasesList['PMTable']) && !empty($this->confCasesList['PMTable'])) {
$c = new Criteria('workflow');
}
else {
$c = $this->addPMFieldsToCriteria('todo');
}
$c->add(AppCacheViewPeer::PRO_UID, $aProcesses, Criteria::IN);
$c->add(AppCacheViewPeer::APP_STATUS, 'TO_DO');
$c->add(AppCacheViewPeer::DEL_FINISH_DATE, null,Criteria::ISNULL);
$c->add(AppCacheViewPeer::APP_THREAD_STATUS, 'OPEN');
$c->add(AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN');
//$c->add(AppCacheViewPeer::APP_NOTIFICACION_ENTREGA, 'NO_NOTIFICADO'); /*<------- This is the filfer or condition i want to add, explication is coming*/
return $c;
}
/**
* gets the ToRevise cases list criteria for count
* param $userUid the current userUid
* @return Criteria object $Criteria
*/
function getNoNotificadoCountCriteria ($userUid) {
return $this->getNoNotificado($userUid, true);
}
/**
* gets the PAUSED cases list criteria for list
* param $userUid the current userUid
* @return Criteria object $Criteria
*/
function getNoNotificadoListCriteria ($userUid) {
return $this->getNoNotificado($userUid, false);
}
Code: Select all
I olso added a field in database (WORKFLOW.APP_CACHE_VIEW table) where i store if case has been notified or not.public function getDefaultFields (){
return array (
...
'APP_OVERDUE_PERCENTAGE',
'APP_NOTIFICACION_ENTREGA',
...
);
}
In workflow\engine\methods\cases\casesListExtJs.php i olso copied the code of "to_revise".
Code: Select all
function getProcessArray ( $action, $userUid ) {
...
switch ( $action ) {
...
case 'no_notificado' :
$cProcess = $oAppCache->getNoNotificadoListCriteria($userUid);
break;
...
}
...
return $processes;
}
Code: Select all
function getStatusArray ( $action, $userUid ) {
...
switch ( $action ) {
...
case 'no_notificado' :
$cStatus = $oAppCache->getNoNotificadoListCriteria($userUid);
break;
...
}
...
return $status;
}
Code: Select all
function getNoNotificado() {
$caseColumns = array ();
$caseColumns[] = array( 'header' => '#', 'dataIndex' => 'APP_NUMBER', 'width' => 45, 'align' => 'center');
$caseColumns[] = array( 'header' => G::LoadTranslation('ID_SUMMARY'), 'dataIndex' => 'CASE_SUMMARY', 'width' => 45, 'align' => 'center', 'sorteable'=>false);
$caseColumns[] = array( 'header' => G::LoadTranslation('ID_CASES_NOTES'), 'dataIndex' => 'CASE_NOTES_COUNT', 'width' => 45, 'align' => 'center', 'sorteable'=>false);
$caseColumns[] = array( 'header' => G::LoadTranslation('ID_CASE'), 'dataIndex' => 'APP_TITLE', 'width' => 150 );
$caseColumns[] = array( 'header' => 'UserUid', 'dataIndex' => 'USR_UID', 'width' => 50, 'hidden'=> true, 'hideable'=> false);
$caseColumns[] = array( 'header' => 'PreUsrUid', 'dataIndex' => 'PREVIOUS_USR_UID','width' => 50, 'hidden'=> true, 'hideable'=> false);
//$caseColumns[] = array( 'header' => G::LoadTranslation('ID_PROCESS'), 'dataIndex' => 'APP_PRO_TITLE', 'width' => 120 , 'hidden'=> true); //Hugo lizama Comentado
$caseColumns[] = array( 'header' => G::LoadTranslation('ID_TASK'), 'dataIndex' => 'APP_TAS_TITLE', 'width' => 120 );
$caseColumns[] = array( 'header' => G::LoadTranslation('ID_SENT_BY'), 'dataIndex' => 'ID_SENT_BY','width' => 90 );
$caseColumns[] = array( 'header' => G::LoadTranslation('ID_CURRENT_USER'),'dataIndex' => 'APP_CURRENT_USER','width' => 90 );
// $caseColumns[] = array( 'header' =>'Sent By', 'dataIndex' => 'APP_DEL_PREVIOUS_USER', 'width' => 90 );
///-- $caseColumns[] = array( 'header' => G::LoadTranslation('ID_LAST_MODIFY'), 'dataIndex' => 'APP_UPDATE_DATE', 'width' => 110 );
//$caseColumns[] = array( 'header' => G::LoadTranslation('ID_PRIORITY'), 'dataIndex' => 'DEL_PRIORITY', 'width' => 50 , 'hidden'=> true); //Hugo lizama Comentado
$caseColumns[] = array( 'header' => G::LoadTranslation('ID_STATUS'), 'dataIndex' => 'APP_STATUS', 'width' => 50 );
//Agregado Hugo Lizama
$caseColumns[] = array( 'header' => G::LoadTranslation('ID_FINISH_DATE'), 'dataIndex' => 'FECHA_FINALIZACION', 'width' => 110 );
$caseColumns[] = array( 'header' => G::LoadTranslation('ESTA_EN'), 'dataIndex' => 'ESTA_EN', 'width' => 110 );
//------------------
$caseReaderFields = array();
$caseReaderFields[] = array( 'name' => 'APP_UID' );
$caseReaderFields[] = array( 'name' => 'USR_UID' );
$caseReaderFields[] = array( 'name' => 'PREVIOUS_USR_UID' );
$caseReaderFields[] = array( 'name' => 'APP_NUMBER' );
$caseReaderFields[] = array( 'name' => 'DEL_INDEX' );
$caseReaderFields[] = array( 'name' => 'APP_TITLE' );
//$caseReaderFields[] = array( 'name' => 'APP_PRO_TITLE' ); //Hugo lizama Comentado
$caseReaderFields[] = array( 'name' => 'APP_TAS_TITLE' );
// $caseReaderFields[] = array( 'name' => 'APP_DEL_PREVIOUS_USER' );
$caseReaderFields[] = array( 'name' => 'APP_CURRENT_USER' );
$caseReaderFields[] = array( 'name' => 'DEL_TASK_DUE_DATE' );
//$caseReaderFields[] = array( 'name' => 'APP_UPDATE_DATE' ); //Hugo lizama Comentado
//$caseReaderFields[] = array( 'name' => 'DEL_PRIORITY' ); //Hugo lizama Comentado
$caseReaderFields[] = array( 'name' => 'APP_STATUS' );
$caseReaderFields[] = array( 'name' => 'APP_FINISH_DATE' );
$caseReaderFields[] = array( 'name' => 'ID_SENT_BY' );
$caseReaderFields[] = array( 'name' => 'CASE_SUMMARY' );
$caseReaderFields[] = array( 'name' => 'CASE_NOTES_COUNT' );
$caseReaderFields[] = array( 'name' => 'FECHA_FINALIZACION' ); //Agregado Hugo Lizama
$caseReaderFields[] = array( 'name' => 'ESTA_EN' ); //Agregado Hugo Lizama
return array ( 'caseColumns' => $caseColumns, 'caseReaderFields' => $caseReaderFields, 'rowsperpage' => 20, 'dateformat' => 'M d, Y' );
}
Code: Select all
Until this part works fine and it shows the cases just like in review option but i want to add the filter i marked above. If i uncomment than line it shows nothing and that is the BIG problem i have.function getAdditionalFields($action){
switch ( $action ) {
...
case 'no_notificado' :
$config = getNoNotificado();
break;
...
}
return $config;
}
I know it wouldn't magically work just like that, so i kept investigating and i found some more code to try.
In workflow\engine\classes\model\om\BaseAppCacheViewPeer.php added
Code: Select all
const APP_NOTIFICACION_ENTREGA = 'APP_CACHE_VIEW.APP_NOTIFICACION_ENTREGA';
Code: Select all
private static $fieldNames = array ( ..., 'AppOverduePercentage', 'AppNotificacionEntrega',),
..., AppCacheViewPeer::APP_OVERDUE_PERCENTAGE, AppCacheViewPeer::APP_NOTIFICACION_ENTREGA, ),
..., 'APP_OVERDUE_PERCENTAGE', 'APP_NOTIFICACION_ENTREGA',),
..., 29, 30, )
);
Code: Select all
private static $fieldKeys = array (..., 'AppOverduePercentage' => 29, 'AppNotificacionEntrega'=>30,),
..., AppCacheViewPeer::APP_OVERDUE_PERCENTAGE => 29, AppCacheViewPeer::APP_NOTIFICACION_ENTREGA=>30,),
..., 'APP_OVERDUE_PERCENTAGE' => 29, 'APP_NOTIFICACION_ENTREGA'=>30, ),
.., 29, 30,)
);
Code: Select all
And the last file i modified is workflow\engine\classes\model\om\BaseAppCacheView.php
public static function addSelectColumns(Criteria $criteria)
{
...
$criteria->addSelectColumn(AppCacheViewPeer::APP_NOTIFICACION_ENTREGA);
...
}
Code: Select all
protected $app_notificacion_entrega = '';
Code: Select all
public function getNotificacionEntrega()
{
return $this->app_notificacion_entrega;
}
Code: Select all
public function setNotificacionEntrega($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->app_notificacion_entrega !== $v || $v === '') {
$this->app_notificacion_entrega = $v;
$this->modifiedColumns[] = AppCacheViewPeer::APP_NOTIFICACION_ENTREGA;
}
}
Code: Select all
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
...
$this->app_notificacion_entrega=$rs->getString($startcol + 30);
...
return $startcol + 31; // 30 = AppCacheViewPeer::NUM_COLUMNS - AppCacheViewPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating AppCacheView object", $e);
}
}
Code: Select all
public function getByPosition($pos)
{
switch($pos) {
...
case 30:
return $this->getNotificacionEntrega();
break;
...
}
Code: Select all
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
...
$keys[30] => $this->getNotificacionEntrega(),
...
);
return $result;
}
Code: Select all
public function setByPosition($pos, $value)
{
switch($pos) {
...
case 30:
$this->setNotificacionEntrega($value);
break;
...
} // switch()
}
Code: Select all
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = AppCacheViewPeer::getFieldNames($keyType);
...
if (array_key_exists($keys[30], $arr)) $this->setNotificacionEntrega($arr[$keys[30]]);
...
}
Code: Select all
public function buildCriteria()
{
$criteria = new Criteria(AppCacheViewPeer::DATABASE_NAME);
...
if ($this->isColumnModified(AppCacheViewPeer::APP_NOTIFICACION_ENTREGA)) $criteria->add(AppCacheViewPeer::APP_NOTIFICACION_ENTREGA, $this->app_notificacion_entrega);
...
return $criteria;
}
Code: Select all
This is what i tried so far and it's not working as i intended, i you read through all of this i already owe you a beer. And if someone can help me will receive a big thank you too.public function copyInto($copyObj, $deepCopy = false)
{
...
$copyObj->setNotificacionEntrega($this->app_notificacion_entrega);
...
}
Last edited by hug0tux on Fri Sep 07, 2012 2:34 pm, edited 1 time in total.