/**
  *
  * Load Slots and Fields for a template
  *
  * @param array $data
  * @return array $result
  */
 public function buildSlots(array $data) {
     $slots = DocumenttemplateSlotTable::instance()->getSlotByDocumentTemplateId($data[0]['id']);
     $result = array();
     $a = 0;
     $columns = 0;
     $colCounter = 0;
     foreach ($slots as $item) {
         $result[$a]['slot_id'] = $item->getId();
         $result[$a]['slot_name'] = $item->getName();
         $result[$a++]['fields'] = $this->buildFields($item->getId());
         
     }
     return $result;
 }
 /**
  * Load all slots for a template
  * @param int $template_id, template id
  * @param string $type, type can be FIELDS -> load fields to a slot, users to a slot, SLOTONLY -> load nothing
  * @return array $result
  */
 public function buildSlots($template_id, $type) {
     $slots = DocumenttemplateSlotTable::instance()->getSlotByDocumentTemplateId($template_id);
     $result = array();
     $a = 0;
     foreach ($slots as $slot) {
         $result[$a]['slot_id'] = $slot->getId();
         $result[$a]['name'] = $slot->getName();
         $result[$a]['receiver'] = $slot->getSendtoallreceivers();
         switch ($type) {
         case 'FIELDS':
             $result[$a]['fields'] = $this->buildFields($slot->getId());
             break;
         case 'SLOTSONLY':
             break;
         }
         $a++;
     }
     return $result;
 }
 public function setNextSlot($nextWorkflowSlotId) {
     $slotData = DocumenttemplateSlotTable::instance()->getSlotByWorkflowSlotId($nextWorkflowSlotId)->toArray();
     $this->nextSlot = $slotData[0];
 }
    public function getCurrentStation($activeversion_id, $sender_id) {
        $result = array();
        $activeVersion = WorkflowProcessTable::instance()->getCurrentStation($activeversion_id);
        $user = $activeVersion[0]->getWorkflowProcessUser()->toArray();
        $workflowslot = $activeVersion[0]->getWorkflowSlot()->toArray();
        if(!empty($workflowslot)) {
            $slot = DocumenttemplateSlotTable::instance()->getSlotById($workflowslot[0]['slot_id'])->toArray();
            $currentStation = $slot[0]['name'];
            $userdata = UserLoginTable::instance()->findActiveUserById($user['user_id'])->toArray();
            $username = $userdata[0]['username'];
            $currentStation .= ' <i>(' . $username . ')</i>';
            $result[0] = $currentStation;
            $result[1] = $workflowslot[0]['updated_at'];
            return $result;
        }

        return $result;
    }