Exemplo n.º 1
0
 public function getRadiogroup($field_id) {
     $result = array();
     $result = FieldRadiogroupTable::instance()->findRadiogroupByFieldId($field_id)->toArray();
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Saves Radiogroup
  *
  * @param int $id, id of the parent field
  * @param array $data, Post data
  */
 public function saveRadiogroup($id, $data) {
     FieldRadiogroupTable::instance()->setRadiogroupToNullById($id);
     if($data['removeItem'] != '') {
         $delted_fields = explode(',', $data['removeItem']);
         Doctrine::getTable('FieldRadiogroup')->createQuery('frg')->whereIn('frg.id', $delted_fields)->execute()->delete();
     }
     $records = $data['grid'];
     $position = 1;
     foreach($records as $item) {
         $radiogroup = $item['databseId'] == '' ? new FieldRadiogroup() : Doctrine::getTable('FieldRadiogroup')->find($item['databseId']);
         $radiogroup->setValue($item['value']);
         $radiogroup->setIsactive($item['checked']);
         $radiogroup->setFieldId($id);
         $radiogroup->setPosition($position++);
         $radiogroup->save();
     }
 }
 /**
  * Add all fields with its values to the slot. Value depends on the flag if old values are used or not
  * @param <type> $type
  * @param <type> $field_id
  * @param <type> $workflowslotfield_id
  * @return <type>
  */
 public function getItems($type, $field_id, $workflowslotfield_id) {
     $result = array();
     $a = 0;
     switch($type) {
         case 'TEXTFIELD':
             if($this->newValue == 0) {
                 $data = FieldTextfieldTable::instance()->getTextfieldByFieldId($field_id)->toArray();
                 $result[0]['value'] = $data[0]['defaultvalue'];
                 return $result;
             }
             else {
                 $data = WorkflowSlotFieldTextfieldTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray();
                 $result[0]['value'] = $data[0]['value'];
                 return $result;
             }
             break;
         case 'CHECKBOX':
             if($this->newValue == 0) {
                 $result[0]['value'] = 0;
                 return $result;
             }
             else {
                 $data = WorkflowSlotFieldCheckboxTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray();
                 $result[0]['value'] = $data[0]['value'];
                 return $result;
             }
             break;
         case 'NUMBER':
             if($this->newValue == 0) {
                 $data = FieldNumberTable::instance()->getNumberByFieldId($field_id)->toArray();
                 $result[0]['value'] = $data[0]['defaultvalue'];
                 return $result;
             }
             else {
                 $data = WorkflowSlotFieldNumberTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray();
                 $result[0]['value'] = $data[0]['value'];
                 return $result;
             }
             break;
         case 'DATE':
             if($this->newValue == 0) {
                 $data = FieldDateTable::instance()->getDateByFieldId($field_id)->toArray();
                 $result[0]['value'] = $data[0]['defaultvalue'];
                 return $result;
             }
             else {
                 $data = WorkflowSlotFieldDateTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray();
                 $result[0]['value'] = $data[0]['value'];
                 return $result;
             }
             break;
         case 'TEXTAREA':
             if($this->newValue == 0) {
                 $data = FieldTextareaTable::instance()->getTextareaByFieldId($field_id)->toArray();
                 $result[0]['value'] = $data[0]['content'];
                 return $result;
             }
             else {
                 $data = WorkflowSlotFieldTextareaTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray();
                 $result[0]['value'] = $data[0]['value'];
                 return $result;
             }
             break;
         case 'RADIOGROUP':
             if($this->newValue == 0) {
                 $data = FieldRadiogroupTable::instance()->findRadiogroupByFieldId($field_id)->toArray();
                 foreach($data as $item) {
                     $result[$a]['value'] = $item['isactive'];
                     $result[$a]['fieldradiogroup_id'] = $item['id'];
                     $result[$a++]['position'] = $item['position'];
                 }
                 return $result;
             }
             else {
                 $data = WorkflowSlotFieldRadiogroupTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray();
                 foreach($data as $item) {
                     $result[$a]['value'] = $item['value'];
                     $result[$a]['fieldradiogroup_id'] = $item['fieldradiogroup_id'];
                     $result[$a++]['position'] = $item['position'];
                 }
                 return $result;
             }
             break;
         case 'CHECKBOXGROUP':
             if($this->newValue == 0) {
                 $data = FieldCheckboxgroupTable::instance()->findCheckboxgroupByFieldId($field_id)->toArray();
                 foreach($data as $item) {
                     $result[$a]['value'] = $item['isactive'];
                     $result[$a]['fieldradiogroup_id'] = $item['id'];
                     $result[$a++]['position'] = $item['position'];
                 }
                 return $result;
             }
             else {
                 $data = WorkflowSlotFieldCheckboxgroupTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray();
                 foreach($data as $item) {
                     $result[$a]['value'] = $item['value'];
                     $result[$a]['fieldradiogroup_id'] = $item['fieldcheckboxgroup_id'];
                     $result[$a++]['position'] = $item['position'];
                 }
                 return $result;
             }
             break;
         case 'COMBOBOX':
             if($this->newValue == 0) {
                 $data = FieldComboboxTable::instance()->findComboboxByFieldId($field_id)->toArray();
                 foreach($data as $item) {
                     $result[$a]['value'] = $item['isactive'];
                     $result[$a]['fieldradiogroup_id'] = $item['id'];
                     $result[$a++]['position'] = $item['position'];
                 }
                 return $result;
             }
             else {
                 $data = WorkflowSlotFieldComboboxTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray();
                 foreach($data as $item) {
                     $result[$a]['value'] = $item['value'];
                     $result[$a]['fieldradiogroup_id'] = $item['fieldcombobox_id'];
                     $result[$a++]['position'] = $item['position'];
                 }
                 return $result;
             }
             break;
         case 'FILE':
             $data = WorkflowSlotFieldFileTable::instance()->getAllItemsByWorkflowFieldId($workflowslotfield_id)->toArray();
             return $data;
             break;
     }
 }
    public function getFieldItems(WorkflowSlotField $field, $type, sfContext $context, $versionid) {
        $result = array();
        $a = 0;
        switch ($type) {
            case 'TEXTFIELD':
                $items = WorkflowSlotFieldTextfieldTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray();
                $fieldData = FieldTextfieldTable::instance()->getTextfieldByFieldId($field->getFieldId())->toArray();
                $replaceObj = new ReplaceTags($versionid, $items[0]['value'], $this->culture, $context);
                $value = $replaceObj->getText();
                $result['value'] = $value;
                $result['regex'] = $fieldData[0]['regex'];
                $result['id'] = $items[0]['id'];
                break;
            case 'CHECKBOX':
                $items = WorkflowSlotFieldCheckboxTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray();
                $result['value'] = $items[0]['value'];
                $result['id'] = $items[0]['id'];
                break;
            case 'NUMBER':
                $items = WorkflowSlotFieldNumberTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray();
                $fieldData = FieldNumberTable::instance()->getNumberByFieldId($field->getFieldId())->toArray();
                if($fieldData[0]['comboboxvalue'] != 'EMPTY') {
                    $result['emptytext'] = $context->getI18N()->__($fieldData[0]['comboboxvalue'] ,null,'field');
                }
                else {
                    $result['emptytext'] = $fieldData[0]['regex'];
                }
                $result['value'] = $items[0]['value'];
                $result['regex'] = $fieldData[0]['regex'];
                $result['id'] = $items[0]['id'];
                break;
            case 'DATE':
                $items = WorkflowSlotFieldDateTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray();
                $format = FieldDateTable::instance()->getDateByFieldId($field->getFieldId())->toArray();
                $result['value'] = $items[0]['value'];
                $result['dateformat'] = $format[0]['dateformat'];
                $result['regex'] = $format[0]['regex'];
                $result['id'] = $items[0]['id'];
                break;
            case 'TEXTAREA':
                $items = WorkflowSlotFieldTextareaTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray();
                $textarea = FieldTextareaTable::instance()->getTextareaById($field->getFieldId())->toArray();
                $result['value'] = $items[0]['value'];
                $result['contenttype'] = $textarea[0]['contenttype'];
                $result['id'] = $items[0]['id'];
                break;
            case 'RADIOGROUP':
                $items = WorkflowSlotFieldRadiogroupTable::instance()->getAllItemsByWorkflowFieldId($field->getId());
                foreach($items as $item) {
                    $name = FieldRadiogroupTable::instance()->getRadiogroupItemById($item->getFieldradiogroupId())->toArray();
                    $result[$a]['value'] = $item->getValue();
                    $result[$a]['id'] = $item->getId();
                    $result[$a++]['name'] = $name[0]['value'];
                }
                break;
            case 'CHECKBOXGROUP':
                $items = WorkflowSlotFieldCheckboxgroupTable::instance()->getAllItemsByWorkflowFieldId($field->getId());
                foreach($items as $item) {
                    $name = FieldCheckboxgroupTable::instance()->getCheckboxgroupItemById($item->getFieldcheckboxgroupId())->toArray();
                    $result[$a]['value'] = $item->getValue();
                    $result[$a]['id'] = $item->getId();
                    $result[$a++]['name'] = $name[0]['value'];
                }
                break;
            case 'COMBOBOX':
                $items = WorkflowSlotFieldComboboxTable::instance()->getAllItemsByWorkflowFieldId($field->getId());
                foreach($items as $item) {
                    $name = FieldComboboxTable::instance()->getComboboxItemById($item->getFieldcomboboxId())->toArray();
                    $result[$a]['value'] = $item->getValue();
                    $result[$a]['id'] = $item->getId();
                    $result[$a++]['name'] = $name[0]['value'];
                }
                break;
            case 'FILE':

                $file = WorkflowSlotFieldFileTable::instance()->getAllItemsByWorkflowFieldId($field->getId())->toArray();
                $workflowtemplate = WorkflowVersionTable::instance()->getWorkflowVersionById($versionid)->toArray();
                $result['filepath'] = sfConfig::get('sf_upload_dir') . '/' . $workflowtemplate[0]['workflowtemplate_id'] . '/' . $versionid . '/' . $file[0]['hashname'] ;
                $result['hashname'] = $file[0]['hashname'];
                $result['filename'] = $file[0]['filename'];
                $url = $this->serverUrl . '/file/ShowAttachment';
                $plainUrl = $this->serverUrl . '/file/ShowAttachment';
                $url .= '/workflowid/' .  $workflowtemplate[0]['workflowtemplate_id'] . '/versionid/' . $versionid. '/attachmentid/' . $file[0]['id'] . '/file/1';
                $plainUrl .= '/workflowid/' .  $workflowtemplate[0]['workflowtemplate_id'] . '/versionid/' . $versionid. '/attachmentid/' . $file[0]['id'] . '/file/1';
                $result['plainurl'] = $plainUrl;
                $result['url'] = $url;
                $result['link'] = '<a href="'.$url.'" target="_blank">'.$result['filename'].'</a>';
                break;
        }
        return $result;
    }