Skip to content
Snippets Groups Projects
approval_chain_manager.xhtml 12.72 KiB
<div id="manager_menu">
    <h2>Select an Approval Chain</h2>
    <ul>
        <li>
            <a href="/ApprovalChainManager/EditChain/new">
                --New Chain--
            </a>
        </li>
        <?php foreach ($this->approvalChains as $approvalChain) { ?>
        <li>
            <a href="/ApprovalChainManager/EditChain/<?php echo $approvalChain->getPrimaryKey(); ?>">
                <?php echo $approvalChain->name; ?>
            </a>
        </li>
        <?php } ?>
    </ul>
</div>


<?php if ($this->approvalChain) { ?>

<div id="manager_edit_pane">
    <h1>Editing Approval Chain <?php echo $this->approvalChain->name; ?></h1>
    <div id="main_details">
        <form method="post" action="/ApprovalChainManager/EditChainPost">
        <?php echo $this->formHidden('chainId', $this->approvalChain->getPrimaryKey(), array('id' => 'chainId')); ?>
            <label>
                Chain Name:
                <?php echo $this->formText('name', $this->approvalChain->name); ?>
                Owner:
                <?php
                $ownerBody = $this->approvalChain->ownerBody;
                if($ownerBody) {
                    $ownerBodyId = $ownerBody->getPrimaryKey();
                } else {
                    $ownerBodyId = null;
                }
                echo $this->formSelect('ownerBody',
                                       $ownerBodyId,
                                       null,
                                       $this->approvalBodies->columnToArray(
                                           'name',
                                           ApprovalBodies::getInstance()->getPrimaryKeyName()
                                       )); ?>
            </label>
            <?php echo $this->formSubmit('submit', 'Update'); ?>
        </form>
    </div>










    <div id="select_links_or_actions">
        <a href="#" id="select_manage_links">Links</a>
        |
        <a href="#" id="select_manage_actions">Actions</a>
    </div>










    <div id="manage_links">
        <form method="post" action="/ApprovalChainManager/AddLinkPost">
            <?php echo $this->formHidden('chainId', $this->approvalChain->getPrimaryKey()); ?>
            <h2>Add Link to Approval Chain</h2>

            <table>
                <tr>
                    <th>Previous Action</th>
                    <th>Resulted In</th>
                    <th>Next Action</th>
                </tr>
                <tr>
                    <td>
                        <?php echo $this->formSelect('currentAction',
                                                     null,
                                                     array('class' => 'actionSelectElement'),
                                                     array('_null' => '--Just Entered Chain--')
                                                     + $this->approvalChain->approvalActions->columnToArray('name', 'approvalActionId')); ?>
                    </td>
                    <td>
                        <?php echo $this->formSelect('currentState', null, null, array('_null' => '--N/A--')); ?>
                    </td>
                    <td>
                        <?php echo $this->formSelect('nextAction', null, null,
                                                     array('_null' => '--Exit Chain--')
                                                     + $this->approvalChain->approvalActions->columnToArray('name', 'approvalActionId')); ?>
                    </td>
                </tr>
            </table>

            <?php echo $this->formSubmit('submit', 'Add Link', null); ?>
        </form>



        <form method="post" action="/ApprovalChainManager/EditLinksPost">
            <?php echo $this->formHidden('chainId', $this->approvalChain->getPrimaryKey()); ?>
            <h2>Edit current Chains</h2>
            <table>
                <tr>
                    <th>Previous Action</th>
                    <th>Resulted In</th>
                    <th>Next Action</th>
                    <th>Delete</th>
                </tr>
                <?php foreach ($this->approvalChain->approvalLinks as $approvalLink) { ?>
                <tr>
                    <td>
                        <?php
                        $currentAction = $approvalLink->currentAction;
                        if($currentAction != null) {
                            $currentActionId = $approvalLink->currentAction->getPrimaryKey();
                            $resultStatusStrings = $currentAction->getTable()->getResultStatusStrings();
                        } else {
                            $currentActionId = '_null';
                            $resultStatusStrings = array();
                        }
                        echo $this->formSelect('edit['. $approvalLink->getPrimaryKey() .'][currentAction]',
                                               $currentActionId,
                                               array('class' => 'actionSelectElement'),
                                               array('_null' => '--Just Entered Chain--')
                                               + $this->approvalChain->approvalActions->columnToArray('name', 'approvalActionId')); ?>
                    </td>
                    <td>
                        <?php echo $this->formSelect('edit['. $approvalLink->getPrimaryKey() .'][currentState]',
                                                     $approvalLink->currentState,
                                                     null,
                                                     array('_null' => '--N/A--')
                                                     + $resultStatusStrings); ?>
                    </td>
                    <td>
                        <?php
                        $nextAction = $approvalLink->nextAction;
                        if($nextAction != null) {
                            $nextActionId = $approvalLink->nextAction->getPrimaryKey();
                        } else {
                            $nextActionId = '_null';
                        }
                        echo $this->formSelect('edit['. $approvalLink->getPrimaryKey() .'][nextAction]',
                                               $nextActionId,
                                               null,
                                               array('_null' => '--Exit Chain--')
                                               + $this->approvalChain->approvalActions->columnToArray('name', 'approvalActionId')); ?>
                    </td>
                    <td>
                        <?php echo $this->formCheckbox('edit[' . $approvalLink->getPrimaryKey() . '][delete]'); ?>
                    </td>
                </tr>
                <?php } ?>
            </table>
            <?php echo $this->formSubmit('submit', 'Update Links'); ?>
        </form>

        <!-- svg:svg version="1.1" baseProfile="full" width="100%" height="510px">
            <svg:rect x="5" y="5" width="500px" height="500px" fill="#cccccc" stroke="#000000" stroke-width="5px"/>
            <svg:ellipse cx="250" cy="60" rx="100px" ry="50px" fill="#00cc00" stroke="#000000" id="ellipseFoo" />
        </svg:svg -->

    </div>














    <div id="manage_actions" style="display:none;">
        <h2>Add New Action</h2>
        <form action="/ApprovalChainManager/AddActionPost" method="post">
            <?php echo $this->formHidden('chainId', $this->approvalChain->getPrimaryKey()); ?>
            <div class="edit_approval_chain">
                <div>
                <label>
                    Name:<br />
                    <?php echo $this->formText('name'); ?>
                </label>
                <label>
                    Type:<br />
                    <?php echo $this->formSelect('type', null,
                                                 array('class' => 'action_type_select'),
                                                 $this->approvalActions); ?>
                </label>
                </div>
                <?php if ($this->approvalChain->getPrimaryKey()) { ?>
                <div class="clear"></div>
                <div>
                <label class="participating_roles">
                    Participating Roles:<br/>
                    <?php echo $this->formSelect('participatingRoles', null,
                                                 array('multiple' => 'multiple'),
                                                 $this->approvalChain->ownerBody->roles->columnToArray(
                                                    'name', ApprovalBodyRoles::getInstance()->getPrimaryKeyName()
                                                 )); ?>
                </label>
                <label class="editing_roles">
                    Editing Roles:<br/>
                    <?php echo $this->formSelect('editingRoles', null,
                                                 array('multiple' => 'multiple'),
                                                 $this->approvalChain->ownerBody->roles->columnToArray(
                                                    'name', ApprovalBodyRoles::getInstance()->getPrimaryKeyName()
                                                 )); ?>
                </label>
                </div>
                <?php } ?>
                <div class="edit_approval_chain_specifics clear"></div>
            </div>
            <?php echo $this->formSubmit('submit', 'Create'); ?>
        </form>



        <h2>Edit Current Actions</h2>
        <form action="/ApprovalChainManager/EditActionPost" method="post">
            <?php echo $this->formHidden('chainId', $this->approvalChain->getPrimaryKey()); ?>
            <?php foreach ($this->approvalChain->approvalActions as $approvalAction) { ?>
            <div class="edit_approval_chain">
                <div>
                    <label>
                        Name: <br/>
                        <?php echo $this->formText('edit[' . $approvalAction->getPrimaryKey() . '][name]',
                                                   $approvalAction->name); ?>
                    </label>
                    <label>
                        Type: <br />
                        <?php echo $this->formSelect('edit[' . $approvalAction->getPrimaryKey() . '][type]',
                                                     $approvalAction->className,
                                                     array('class' => 'action_type_select'),
                                                     $this->approvalActions); ?>
                    </label>
                </div>
                <div class="clear"></div>
                <div>
                    <label class="participating_roles">
                        Participating Roles:<br/>
                        <?php echo $this->formSelect('edit[' . $approvalAction->getPrimaryKey() . '][participatingRoles]',
                                                     $approvalAction->participants->columnToArray(
                                                         ApprovalBodyRoles::getInstance()->getPrimaryKeyName()
                                                     ),
                                                     array('multiple' => 'multiple'),
                                                     $this->approvalChain->ownerBody->roles->columnToArray(
                                                         'name', ApprovalBodyRoles::getInstance()->getPrimaryKeyName()
                                                     )); ?>
                    </label>
                    <label class="editing_roles">
                        Editing Roles:<br/>
                        <?php echo $this->formSelect('edit[' . $approvalAction->getPrimaryKey() . '][editingRoles]',
                                                     $approvalAction->getEditingParticipants()->columnToArray(
                                                         ApprovalBodyRoles::getInstance()->getPrimaryKeyName()
                                                     ),
                                                     array('multiple' => 'multiple'),
                                                     $this->approvalChain->ownerBody->roles->columnToArray(
                                                         'name', ApprovalBodyRoles::getInstance()->getPrimaryKeyName()
                                                     )); ?>
                    </label>
                    <label>
                        Delete: <br />
                        <?php echo $this->formCheckbox('edit[' . $approvalAction->getPrimaryKey() . '][delete]'); ?>
                    </label>
                </div>
                <div class="edit_approval_chain_specifics clear">
                    <?php include $approvalAction->getTable()->getEditTemplate(); ?>
                </div>
            </div>
            <?php } ?>
            <?php echo $this->formSubmit('submit', 'Update'); ?>
        </form>
    </div>
</div>
<?php } ?>