public function view() { if (!$this->loadData()) { $this->dataError(); sendBack(); } $mappingrule = $this->_uses[$this->modeltype]; $this->view->set('clickaction', 'view'); $this->view->set('mappingrule', $mappingrule); $childrules = new DataMappingRuleCollection(new DataMappingRule()); $sh = $this->setSearchHandler($childrules); $sh->addConstraint(new Constraint('parent_id', '=', $mappingrule->id)); parent::index($childrules, $sh); $sidebar = new SidebarController($this->view); $sidebar->addList('actions', array($mappingrule->name => array('tag' => 'View All Mapping Rules', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index')))); $sidebarlist = array(); $sidebarlist[$mappingrule->name] = array('tag' => 'view', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', 'id' => $mappingrule->id)); $sidebarlist['edit'] = array('tag' => 'edit', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', 'id' => $mappingrule->id)); $sidebarlist['delete'] = array('tag' => 'delete', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'delete', 'id' => $mappingrule->id)); $sidebar->addList($mappingrule->external_system . ' ' . $mappingrule->name, $sidebarlist); if (!is_null($mappingrule->parent_id)) { $mappingrule->addLinkRule(array('data_translations' => array())); } $this->sidebarRelatedItems($sidebar, $mappingrule); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); $this->view->set('page_title', $this->getPageName()); }
public function index() { $this->view->set('clickaction', 'view'); parent::index(new ExternalSystemCollection($this->_templateobject)); $sidebar = new SidebarController($this->view); $sidebar->addList('Actions', array('new' => array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'new'), 'tag' => 'new external system'))); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); }
public function index() { $this->view->set('clickaction', 'view'); $collection = new EDITransactionLogCollection($this->_templateobject); $sh = $this->setSearchHandler($collection); if (isset($this->_data['data_definition_id'])) { $sh->addConstraint(new COnstraint('data_definition_id', '=', $this->_data['data_definition_id'])); $datadef = new DataDefinition(); $datadef->load($this->_data['data_definition_id']); $this->view->set('datadef', $datadef); } parent::index(new EDITransactionLogCollection($this->_templateobject), $sh); $sidebar = new SidebarController($this->view); $sidebar->addList('Actions', array('new' => array('link' => array('modules' => $this->_modules, 'controller' => 'externalsystems', 'action' => 'index'), 'tag' => 'view external systems'))); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); }
public function view() { if (!$this->loadData()) { $this->dataError(); sendBack(); } $mapping = $this->_uses[$this->modeltype]; $this->view->set('clickcontroller', 'datamappingrules'); $this->view->set('linkvaluefield', 'data_mapping_rule_id'); $this->view->set('clickaction', 'view'); $this->view->set('mapping', $mapping); $mapping_rule_ids = array(); foreach ($mapping->data_mapping_rules as $mappingrule) { $mapping_rule_ids[] = $mappingrule->id; } // echo '<pre>'.implode(',', $mapping_rule_ids).'</pre><br>'; $definitiondetails = new DataDefinitionDetailCollection(new DataDefinitionDetail()); $sh = $this->setSearchHandler($definitiondetails); $cc = new ConstraintChain(); $cc->add(new Constraint('data_mapping_id', '=', $mapping->id)); $sh->addConstraintChain($cc); if (count($mapping_rule_ids) > 0) { $cc = new ConstraintChain(); $cc->add(new Constraint('data_mapping_rule_id', 'in', '(' . implode(',', $mapping_rule_ids) . ')')); $sh->addConstraintChain($cc, 'OR'); } parent::index($definitiondetails, $sh); $sidebar = new SidebarController($this->view); $sidebar->addList('actions', array($mapping->name => array('tag' => 'View All Mappings', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index')))); $sidebarlist = array(); $sidebarlist[$mapping->name] = array('tag' => 'view', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', 'id' => $mapping->id)); $sidebarlist['edit'] = array('tag' => 'edit', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', 'id' => $mapping->id)); $sidebarlist['delete'] = array('tag' => 'delete', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'delete', 'id' => $mapping->id)); if (!is_null($mapping->internal_type) && $mapping->isLookupModel()) { $sidebarlist['Add Mapping Detail'] = array('tag' => 'add ' . $mapping->name . ' mapping', 'link' => array('modules' => $this->_modules, 'controller' => 'datamappingdetails', 'action' => 'new', 'mapping_id' => $mapping->id)); } $sidebar->addList($mapping->name . ' Mapping', $sidebarlist); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); }
public function view() { if (!$this->loadData()) { $this->dataError(); sendBack(); } $datadef = $this->_uses[$this->modeltype]; $edi = $datadef->setEdiInterface(); $this->view->set('datadefinition', $datadef); $flash = Flash::Instance(); $errors = array(); if (!$edi->isValid()) { $flash->addError('Error getting EDI definition'); sendBack(); } $type = $datadef->direction == 'IN' ? 'import' : 'export'; $this->view->set('type', prettify($type)); if (!isset($this->_data['page'])) { $action = $datadef->direction == 'IN' ? 'AD' : 'AE'; $filelist = $edi->getFileList($errors); if (count($errors) == 0 && $filelist) { // Update log with list of items awaiting download or export $edi->writeLogs($filelist, $action, $errors); } } $edilog = new EDITransactionLog(); $edilogs = new EDITransactionLogCollection($edilog); $sh = $this->setSearchHandler($edilogs); $db = DB::Instance(); $filename = $datadef->file_prefix . '%' . (!is_null($datadef->file_extension) ? '.' . strtolower($datadef->file_extension) : null); $cc = new ConstraintChain(); $cc->add(new Constraint('status', '=', 'E')); $cc->add(new Constraint('name', 'like', $filename)); $cc->add(new Constraint('data_definition_id', '=', $datadef->id)); if ($datadef->direction == 'IN') { $cc->add(new Constraint('action', 'in', "('AD', 'AI', 'D', 'I')")); } else { $cc->add(new Constraint('action', 'in', "('AE', 'E', 'S')")); } $this->view->set('errors', $edilog->getCount($cc)); $cc1 = new ConstraintChain(); if ($this->_data['action_type'] == 'ERR') { $cc1 = $cc; } else { $cc1->add(new Constraint('status', '=', 'N')); $cc1->add(new Constraint('data_definition_id', '=', $datadef->id)); $cc1->add(new Constraint('name', 'like', $filename)); $cc2 = new ConstraintChain(); $cc3 = new ConstraintChain(); $cc3->add(new Constraint('status', '=', 'E')); if ($datadef->direction == 'IN') { $cc2->add(new Constraint('action', 'in', "('AD', 'AI', 'D')")); $cc3->add(new Constraint('action', '=', 'I')); } else { $cc2->add(new Constraint('action', 'in', "('AE', 'E')")); $cc3->add(new Constraint('action', '=', 'S')); } $cc2->add($cc3, 'OR'); $cc1->add($cc2); } $sh->addConstraintChain($cc1); parent::index($edilogs, $sh); if (count($errors) > 0) { $errors[] = 'Error getting ' . $type . ' list'; $flash = Flash::Instance(); $flash->addErrors($errors); } $this->view->set('edilogs', $edilogs); $sidebar = new SidebarController($this->view); $sidebarlist = array(); $sidebarlist['view_all'] = array('tag' => 'View All Transfer Types', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index')); $sidebarlist['upload_files'] = array('tag' => 'upload files', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'upload_file')); $sidebar->addList('actions', $sidebarlist); $action = $datadef->direction == 'IN' ? 'Import' : 'Export'; $sidebarlist = array(); $sidebarlist[$datadef->name . $action] = array('tag' => 'view outstanding files to ' . $action, 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', 'id' => $datadef->id, 'implementation_class' => $datadef->implementation_class)); $sidebarlist[$datadef->name . 'errors'] = array('tag' => 'view outstanding error files', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', 'action_type' => 'ERR', 'id' => $datadef->id, 'implementation_class' => $datadef->implementation_class)); $sidebarlist['edit'] = array('tag' => 'edit', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', 'id' => $datadef->id, 'implementation_class' => $datadef->implementation_class)); $sidebarlist['delete'] = array('tag' => 'delete', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'delete', 'id' => $datadef->id, 'implementation_class' => $datadef->implementation_class)); if ($datadef->transfer_type == 'LOCAL' && $datadef->direction == 'IN') { $sidebarlist['upload'] = array('tag' => 'upload file', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'upload_file', 'id' => $datadef->id)); } $sidebar->addList($datadef->name, $sidebarlist); $this->sidebarRelatedItems($sidebar, $datadef); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); }
public function _new() { $datamapdetail = $this->_uses[$this->modeltype]; if ($datamapdetail->isLoaded()) { $this->_data['data_mapping_rule_id'] = $datamapdetail->data_mapping_rule_id; $this->_data['parent_id'] = $datamapdetail->parent_id; $datamappingrule = $datamapdetail->data_map_rule; } elseif (isset($this->_data['data_mapping_rule_id'])) { $datamappingrule = new DataMappingRule(); $datamappingrule->load($this->_data['data_mapping_rule_id']); } if (!$this->CheckParams('data_mapping_rule_id')) { sendBack(); } parent::_new(); $cc = new ConstraintChain(); $datamap = $datamappingrule->data_map; $options = array(); if (!empty($this->_data['parent_id'])) { // get the parent mapping detail $parent_detail = new DataMappingDetail(); $parent_detail->load($this->_data['parent_id']); // get the parent mapping $parent_mapping = $parent_detail->data_map_rule->data_map; $parent_id = $parent_detail->internal_code; // Rules need simplifying and/or explaining // perhaps move these to the DataMapping model $x = $datamap->getModel(); $hasmany = $x->getHasMany(); if (isset($hasmany[$datamap->internal_attribute])) { $x->load($parent_detail->internal_code); foreach ($x->{$datamap->internal_attribute} as $detail) { $options[$detail->{$detail->idField}] = $detail->{$detail->getIdentifier()}; } } elseif ($parent_mapping->isHasOne()) { $hasone = $parent_mapping->getHasOne(); $x = new $hasone['model'](); $hasmany = $x->getHasMany(); if (isset($hasmany[$datamap->internal_attribute])) { $x->load($parent_detail->internal_code); foreach ($x->{$datamap->internal_attribute} as $detail) { $options[$detail->{$detail->idField}] = $detail->{$detail->getIdentifier()}; } } } else { $belongsto = $x->belongsTo; foreach ($belongsto as $parent) { if ($parent['model'] == $parent_mapping->internal_type) { $cc->add(new Constraint($parent['field'], '=', $parent_id)); break; } } } // If no constraints found from fk definitions and the parent class is the // same as the child class, then the parent is the child i.e. data specific // to the parent if (empty($cc->constraints) && $parent_mapping->internal_type == get_class($x)) { $cc->add(new Constraint($x->idField, '=', $parent_id)); } } // elseif (!is_null($datamappingrule->parent_id)) { // Get the list of parent options // from the parent mapping details via the parent mapping rule $parentmappingrule = new datamappingrule(); $parentmappingrule->load($datamappingrule->parent_id); $parent_options = array(); foreach ($parentmappingrule->data_translations as $parent_detail) { $parent_options[$parent_detail->id] = $parent_detail->displayValue(); } $this->view->set('parent_options', $parent_options); $this->view->set('parent_label', $datamappingrule->parent); // } if (is_null($datamap->internal_type)) { $errors[] = 'No Internal Type defined for Data Mapping ' . $datamappingrule->name; } else { if (empty($options)) { $options = $datamap->getDataOptions($datamap->getModel(), $cc); } $this->view->set('data_mapping_rule_id', $this->_data['data_mapping_rule_id']); if (!$datamap->isLoaded()) { $errors[] = 'Invalid Data Type'; } else { if (!is_null($datamap->internal_type)) { $model = $datamap->getModel(); if (!$model) { $errors[] = 'Data Mapping for Internal Data Type is invalid'; } else { $this->view->set('model', $model); $this->view->set('internal_codes', $options); $this->view->set('internal_name', $datamappingrule->name); } } } } $datatranslations = new DataMappingDetailCollection(new DataMappingDetail()); $sh = $this->setSearchHandler($datatranslations); $sh->addConstraint(new Constraint('data_mapping_rule_id', '=', $this->_data['data_mapping_rule_id'])); if (isset($this->_data['parent_id'])) { $sh->addConstraint(new Constraint('parent_id', '=', $this->_data['parent_id'])); } parent::index($datatranslations, $sh); $this->view->set('clickaction', 'view'); }