コード例 #1
0
ファイル: BaseObject.php プロジェクト: kafruhs/fws
    /**
     * set data
     */
    public function setData()
    {
        $requestHelper = $this->controller->getRequestHelper();
        $class = $requestHelper->getParam('class');
        $viewMode = $requestHelper->getParam('mode');

        if (!in_array($viewMode, array(DisplayClass::EDIT, DisplayClass::VIEW))) {
            $viewMode = DisplayClass::VIEW;
        }

        $obj = Factory::loadObject($class, $requestHelper->getParam('LK'));
        if (is_null($obj)) {
            $obj = Factory::createObject($class);
        }
        $this->obj = $obj;

        $user = Flat::user();
        $dataPermission = DataPermission::createObject($obj);
        if (!User::isLoggedIn() || !$user->isEntitled($obj->getPermissionForViewMode($viewMode)) || !$dataPermission->isUserOccupant($user->getLogicalKey())) {
            $viewMode = DisplayClass::VIEW;
        }

        $formModel = new base_form_Model($obj, $viewMode);
        $formModel->setAjaxForm('base_ajax_save_Controller');
        $formModel->setMethod(base_form_Model::METHOD_POST);
        $formModel->addAction("&class=$class");
        $formModel->addAction("&caller=" . $this->controller->getCallerSection());
        $formModel->setId('inputData');
        $this->data = new base_form_View($formModel);
    }
コード例 #2
0
ファイル: MnConnection.php プロジェクト: kafruhs/fws
 /**
  * show the data in an input element for editing
  *
  * @return string
  */
 protected function getWriteDisplay()
 {
     $selectedOptionNames = explode(', ', $this->value);
     $output = Html::startTag('div', ['class' => $this->class]);
     $connectedClassName = $this->fieldinfo->getConnectedClass();
     /** @var BaseConnectionObject $connObj */
     $connObj = new $connectedClassName();
     $class = $connObj->getOtherClass($this->fieldinfo->getClass());
     $obj = Factory::createObject($class);
     $connectedFieldName = $this->fieldinfo->getFieldsOfConnectedClass();
     $table = DB::table($obj->getTable());
     $result = Finder::create($class)->find([$table->getColumn($connectedFieldName), $table->getColumn('LK')]);
     foreach ($result as $row) {
         $params = [];
         $params['value'] = $row['LK'];
         $params['type']  = 'checkbox';
         $params['class'] = 'checkbox';
         $params['name']  = $this->name . '[]';
         if (in_array($row[$connectedFieldName], $selectedOptionNames)) {
             $params['checked'] = 'checked';
         }
         $output .= Html::startTag('p') . Html::singleTag('input', $params) . " " . $row[$connectedFieldName] . Html::endTag('p');
     }
     $output .= Html::endTag('div');
     return $output;
 }
コード例 #3
0
ファイル: Check.php プロジェクト: kafruhs/fws
 public static function classNameInstanceOfBaseObject($className)
 {
     $obj = Factory::createObject($className);
     if ($obj instanceof BaseObject === false) {
         throw new BaseException(TMS(BaseException::CLASS_NOT_INSTANCEOF_BASOBJECT, array('class' => $className)));
     }
 }
コード例 #4
0
ファイル: Model.php プロジェクト: kafruhs/fws
 /**
  * set data
  */
 public function setData()
 {
     $obj = Factory::createObject('News');
     $table = DB::table($obj->getTable());
     $limit = new base_database_Limit(10);
     $order = DB::order($table->getColumn('firstEditTime'));
     $finder = Finder::create('news')->setOrder($order)->setlimit($limit);
     $this->data = $finder->find();
 }
コード例 #5
0
ファイル: FKVendor.php プロジェクト: kafruhs/fws
 public function mapFieldValue($value)
 {
     $obj = Factory::createObject('vendor');
     $table = DB::table($obj->getTable());
     $where = DB::where($table->getColumn('name'), DB::term($value));
     $finder = Finder::create('vendor')->setWhere($where);
     $result = $finder->find(array($table->getColumn('LK')));
     if (count($result) > 1) {
         throw new base_exception_Mapper(TMS('medexchange.exception.mapper.vendorDuplicatedEntry'));
     }
     $lkArray = $result[0];
     return $lkArray['LK'];
 }
コード例 #6
0
ファイル: Lk.php プロジェクト: kafruhs/fws
    public function fromDBToExternal($value)
    {
        $obj = Factory::createObject($this->fi->getConnectedClass());
        $select = new base_database_statement_Select();
        $table = DB::table($obj->getTable());
        $where = DB::where($table->getColumn('LK'), DB::intTerm((int) $value));
        $select->setTable($table);
        $select->setWhere($where);
        $select->setColumns(array($table->getColumn($this->fi->getFieldsOfConnectedClass())));
        $result = $select->fetchDatabase();
        $value = current($result);
        return $value[$this->fi->getFieldsOfConnectedClass()];

    }
コード例 #7
0
ファイル: Navigation.php プロジェクト: kafruhs/fws
 public function loadEntriesForCategory($catLK)
 {
     $navEntry = Factory::createObject('NavigationEntry');
     $table = DB::table($navEntry->getTable());
     $where = DB::where($table->getColumn('category'), DB::intTerm($catLK));
     $entries = Finder::create('navigationEntry')->setWhere($where)->find();
     $relevantEntries = [];
     foreach ($entries as $entry) {
         if ($this->_isEntitledForEntry($entry)) {
             $relevantEntries[] = $entry;
         }
     }
     return $relevantEntries;
 }
コード例 #8
0
ファイル: FKcollocgroup.php プロジェクト: kafruhs/fws
    /**
     * converts a given value to the specified structure
     *
     * @param $value
     * @return mixed
     * @throws base_database_Exception
     * @throws base_exception_Mapper
     */
    public function mapFieldValue($value)
    {
        $obj = Factory::createObject('TSMCollocgroup');
        $table = DB::table($obj->getTable());
        $where = DB::where($table->getColumn('name'), DB::term($value));
        $where->addAnd($table->getColumn('FK_tsmserver'), DB::term(TSMServerManager::get()->getActualTsmServerLK()));
        $finder = Finder::create('TSMCollocgroup')->setWhere($where);
        $result = $finder->find(array($table->getColumn('LK')));

        if (count($result) > 1) {
            throw new base_exception_Mapper(TMS('tsmviewer.exception.mapper.collocgroupDuplicatedEntry'));
        }

        $lkArray = current($result);

        return $lkArray['LK'];
    }
コード例 #9
0
ファイル: Model.php プロジェクト: kafruhs/fws
 protected function getData()
 {
     $requestHelper = $this->controller->getRequestHelper();
     $pzn = $requestHelper->getParam('pzn');
     $obj = Factory::createObject('medicament');
     $table = DB::table($obj->getTable());
     $where = DB::where($table->getColumn('pzn'), DB::term($pzn));
     $finder = Finder::create('medicament')->setWhere($where);
     $result = $finder->find();
     if (empty($result)) {
         return array();
     }
     /** @var BaseObject $obj */
     $obj = $result[0];
     foreach ($obj->getAllFields() as $fi) {
         if ($fi->getDisplayClass() == 'system') {
             continue;
         }
         $values[$fi->getFieldName()] = $obj->getField($fi->getFieldName());
     }
     return $values;
 }
コード例 #10
0
ファイル: Flat.php プロジェクト: kafruhs/fws
    /**
     * get the actual logged in User
     *
     * @return User|null
     */
    public static function user()
    {
        if (isset($GLOBALS['argv'])) {
            if (isset($GLOBALS['user'])) {
                return $GLOBALS['user'];
            }
            $GLOBALS['user'] = new User();
            $GLOBALS['user']->load(1);
            return $GLOBALS['user'];
        }

        if (!User::isLoggedIn()) {
            return Factory::createObject('User');
        }

        $user = $_SESSION['user'];

        if (! $user instanceof User) {
            return Factory::createObject('user');
        }
        return $user;
    }
コード例 #11
0
ファイル: Model.php プロジェクト: kafruhs/fws
    /**
     * execute the actual ajax request
     */
    protected function executeRequest()
    {
        $requestHelper = $this->controller->getRequestHelper();
        $class = $requestHelper->getParam('class');
        $object = Factory::createObject($class);
        /** @var BaseObject[] $result */
        $result = Finder::create($class)->find();
        $urlColumns = $requestHelper->getParam('cols');

        if (!is_null($urlColumns)) {
            if ($urlColumns == 'all') {
                $fi = new Fieldinfo($class);
                $columnNames = $fi->getAllFieldNames();
            } else {
                $columnNames = explode(',', $urlColumns);
            }
        } else {
            $columnNames = $object->getStdSearchColumns();
        }

        $response = new stdClass();


        $i = 0;
        foreach ($result as $obj) {
            $values = [];
            $values['LK'] = (int) $obj['LK'];
            foreach ($columnNames as $colName) {
                $values[$colName] = $obj->getField($colName);
            }

            $response->BaseObjectReader[] = $values;
            $i++;
        }
        $jsonObject = json_encode($response);
        echo $jsonObject;
        exit();
    }
コード例 #12
0
ファイル: User.php プロジェクト: kafruhs/fws
    /**
     * login of an user with the given userid and password
     *
     * @param string $userid
     * @param string $password
     *
     * @return int
     * @throws base_database_Exception
     */
    public static function login($userid, $password)
    {
        $table = DB::table(Factory::createObject('user')->getTable());
        $where = DB::where($table->getColumn('userid'), DB::stringTerm($userid));
        $res = Finder::create('user')->setWhere($where)->find();

        if (empty($res)) {
            return self::LOGIN_FAILURE;
        }
        $user = current($res);
        if ($user['disabled'] == self::USER_DISABLED) {
            return self::LOGIN_USER_DISABLED;
        }
        if ($user['password'] != md5($password)) {
            return self::_updateLoginTries($table, $user);
        }

        try {
            $time = new base_date_model_DateTime();
            $updateData = array(
                'ip' => DB::stringTerm($_SERVER['REMOTE_ADDR']),
                'sessionid' => DB::stringTerm(session_id()),
                'lastLogin' => DB::stringTerm($time->toDB()),
                'loginTries' => DB::intTerm(0),
            );
            self::_updateUserLoginData($table, $where, $updateData);
        } catch (Exception $e) {
            return self::LOGIN_FAILURE;
        }
        $user['ip'] = $_SERVER['REMOTE_ADDR'];
        $user['sessionid'] = session_id();
        $user['lastLogin'] = $time;
        $user['loginTries'] = 0;
        $_SESSION['user'] = $user;

        return self::LOGIN_SUCCESS;
    }
コード例 #13
0
ファイル: Model.php プロジェクト: kafruhs/fws
    /**
     * execute the actual ajax request
     */
    protected function executeRequest()
    {
        $error = '';
        $requestHelper = $this->controller->getRequestHelper();
        try {
            $class = $requestHelper->getParam('class');
            $lk = (int) $requestHelper->getParam('LK');
            if (!empty($lk)) {
                $obj = Factory::loadObject($class, $lk);
            } else {
                $obj = Factory::createObject($class);
            }

            foreach ($requestHelper->getAllParams() as $fieldName => $value) {

                try {
                    $fi = $obj->getFieldinfo($fieldName);
                    if ($fi->isMandatory() && empty($value) && $fieldName != 'LK') {
                        $error .= TMS(base_exception_Fieldinfo::FIELD_IS_MANDATORY, array('field' => $fi->getFieldLabel())) . "<br />";
                    }
                    $obj[$fieldName] = $value;
                } catch (Exception $e) {

                }
            }
            if (empty($error)) {
                $dbObj = base_database_connection_Mysql::get();
                $dbObj->beginTransaction();
                $ret = $obj->save();
                $dbObj->endTransaction();
            }
        } catch (Exception $e) {
            $error = $e->getMessage();
        }

        if (!empty($error)) {
            $this->msg = $error;
            return;
        }

        if ($this->controller->getCallerSection() == base_ajax_Controller::CALLER_SECTION_ACP) {
            $url = 'de/acp';
        } else {
            $url = 'de/';
        }
        switch ($requestHelper->getParam('referer')) {
            case base_form_View::SAVE_AND_EDIT:
                $this->returnCode = self::STAY_ON_ACTUAL_PAGE;
                break;
            case base_form_View::SAVE_AND_NEW:
                $this->returnCode = self::PROCEED_TO_NEXT_PAGE;
                $this->setRedirectUrl($url . '/frontend.php?controller=base_pages_input_controller_BaseObject&class=' . $class . '&mode=edit');
                break;
            case base_form_View::SAVE_AND_SEARCH:
                $this->returnCode = self::PROCEED_TO_NEXT_PAGE;
                $this->setRedirectUrl($url . '/frontend.php?controller=base_pages_search_controller_TableList&class=' . $class . '&mode=edit');
                break;
        }

        if ($ret == BaseObject::SAVE_SUCCESS) {
            $this->msg = "Der Datensatz wurde erfolgreich gespeichert.";
            return;
        }
        $this->returnCode = self::STAY_ON_ACTUAL_PAGE;
        if ($ret == BaseObject::SAVE_FAILURE) {
            $this->msg = "Der Datensatz konnte nicht gespeichert werden";
            return;
        }
        $this->msg = "Es wurden keine Veränderungen am Datensatz vorgenommen";
    }
コード例 #14
0
ファイル: Finder.php プロジェクト: kafruhs/fws
 /**
  * @param string $className
  */
 protected function __construct($className)
 {
     $obj = Factory::createObject($className);
     $this->class = $className;
     $this->table = DB::table($obj->getTable());
 }
コード例 #15
0
ファイル: PDFCreator.php プロジェクト: kafruhs/fws
    public function Output($name = 'doc.pdf', $dest = 'F', $description = '')
    {
        DB::beginTransaction();
        $file = Factory::createObject('file');
        $path = ROOT . "/files/order/" . $name;
        $file['name'] = $name;
        $file['link'] = HTML_ROOT . '/files/order/' . $name;
        $obj = $this->data[0];
        if (empty($description)) {
            $description = "PDF vom " . date("d.m.Y H:i:s", time()) . " Uhr zur Objekt-Klasse " . get_class($obj);
        }
        $file['description'] = $description;

        $file->save();
        DB::endTransaction();

        parent::Output($path, $dest);
        $this->path = $path;
    }
コード例 #16
0
ファイル: offer.php プロジェクト: kafruhs/fws
                $formElement->setName($fi->getFieldName());
                $formElement->setValue($obj->getField($fi->getFieldName()));
                $displayClassName = 'base_displayclass_' . ucfirst($fi->getDisplayClass());
                /** @var DisplayClass $dpC */
//                $dpC = new $displayClassName($obj);
//                $displayMode = $dpC->getDisplayMode(DisplayClass::VIEW);
                $formElement->setDisplayMode(DisplayClass::VIEW);
                $cell = new base_html_model_table_Cell();
                $cell->setCssID($fi->getFieldName());
                $cell->setCssClass($formElement->getClass());
                $cell->setContent($formElement->display());
                $row->addCell($cell);
            }
            $cell = new base_html_model_table_Cell();
            $cell->setCssClass('orderAmount');
            $medOrder = Factory::createObject('MedOrder');
            $fi = $medOrder->getFieldinfo('amount');
            $formElement = base_form_element_Factory::createElement($fi);
            $formElement->setClass($formElement->getClass() . ' orderAmount');
            $formElement->setMultiline();
            $formElement->setName('orderAmount');
            $formElement->setValue(0);
            $formElement->setDisplayMode(DisplayClass::EDIT);
            $content = $formElement->display();
            $formElement = new base_form_element_Hidden($obj->getFieldinfo('LK'));
            $formElement->setMultiline();
            $formElement->setName('LK');
            $value = $obj['LK'];
            $formElement->setValue($value);
            $content .= " " . $formElement->display();
            $cell->setContent($content);
コード例 #17
0
ファイル: searchObject.php プロジェクト: kafruhs/fws
base_ui_Site::displayTop($od);
base_ui_Site::displayNavigation($od);
base_ui_Site::startMainContent($od);

print $od->toString();
$od->flush();

$requestHelper = new RequestHelper();

$class = $requestHelper->getParam('class');

if (is_null($class)) {
    throw new base_exception_Site(TMS(base_exception_Site::PARAM_MISSING, array('param' => 'class')));
}

$object = Factory::createObject($class);

$user = Flat::user();

if (!User::isLoggedIn() || !$user->isEntitled($object->getPermissionForViewMode(DisplayClass::VIEW))) {
    $od->addContent('Sie verfügen nicht über die benötigten Rechte, um diese Datenkategorie zu betrachten. Bitte wenden Sie sich an den Support');
    base_ui_Site::endMainContent($od);
    base_ui_Site::displayBottom($od);

    print $od->toString();
    exit();
}

$urlColumns = $requestHelper->getParam('cols');
if (!is_null($urlColumns)) {
    if ($urlColumns == 'all') {
コード例 #18
0
ファイル: showHistory.php プロジェクト: kafruhs/fws
$od = new OutputDevice();

base_ui_Site::displayHead($od);
base_ui_Site::displayTop($od);
base_ui_Site::displayNavigation($od);
base_ui_Site::startMainContent($od);

print $od->toString();
$od->flush();

$od->addContent(Html::startTag('h3'));
$od->addContent('Summary');
$od->addContent(Html::endTag('h3'));

$table = DB::table(Factory::createObject('TSMSummary')->getTable());
$dateTime = new base_date_model_DateTime(new DateTime('2015-01-01 00:00:00'));
$where = DB::where($table->getColumn('startTime'), DB::term($dateTime->toDB()), base_database_Where::GREATER);
$order = DB::order($table->getColumn('startTime'));
$finder = Finder::create('TSMSummary')->setWhere($where)->setOrder($order);
$objs = $finder->find();

$times = [];
$nodeNames = [];
$sortedObjects = [];
foreach ($objs as $obj) {
    /** @var base_date_model_DateTime $startTime */
    $startTime = $obj['startTime'];
    $nodeName = $obj['nodeName'];
    if (strpos($nodeName, 'FULLVM')) {
        $nodeName = $obj['subEntity'] . ' (FULLVM)';
コード例 #19
0
ファイル: Model.php プロジェクト: kafruhs/fws
 private function _setSort()
 {
     $obj = Factory::createObject($this->class);
     $table = DB::table($obj->getTable());
     $order = new base_database_Order($table->getColumn($this->params['sort']), $this->params['direction']);
     $this->sort = $order;
 }
コード例 #20
0
ファイル: login.php プロジェクト: kafruhs/fws
$od->addContent(Html::endTag('h3'));

print $od->toString();
$od->flush();


if (User::isLoggedIn()) {
    $od->addContent('Zum Ausloggen bitte ' . Html::url(HTML_ROOT . '/' . Flat::language() . '/logout.php', 'hier') . "klicken\n");
} else {
    $od->addContent("<form method='post' action='ajax.php?controller=base_ajax_login_Controller&redirect=index.php' class='ajaxForm' >\n");
    $table = new base_html_model_Table();
    
    $labelCell = new base_html_model_table_Cell();
    $labelCell->setContent('Benutzername');
    $valueCell = new base_html_model_table_Cell();
    $obj = Factory::createObject('user');
    $inputUserName = base_form_element_Factory::createElement($obj->getFieldinfo('userid'));
    $inputUserName->setName('userid');
    $inputUserName->setDisplayMode(DisplayClass::EDIT);
    $valueCell->setContent($inputUserName->display());
    $rowUserId = new base_html_model_table_Row();
    $rowUserId->addCell($labelCell);
    $rowUserId->addCell($valueCell);
    $table->addRow($rowUserId);

    $labelCell = new base_html_model_table_Cell();
    $labelCell->setContent('Passwort');
    $valueCell = new base_html_model_table_Cell();
    $inputPassword = base_form_element_Factory::createElement($obj->getFieldinfo('password'));
    $inputPassword->setName('password');
    $inputPassword->setDisplayMode(DisplayClass::EDIT);
コード例 #21
0
ファイル: inputMedOffer.php プロジェクト: kafruhs/fws
$od->addContent('Eingabe eines Biete-Artikels');
$od->addContent(Html::endTag('h3'));

if (!User::isLoggedIn()) {
    $od->addContent('Sie sind nicht eingeloggt');
} else {


    $requestHelper = new RequestHelper();
    $lk = $requestHelper->getParam('lk');
    $medOffer = null;
    if (!is_null($lk)) {
        $medOffer = Factory::loadObject('medOffer', (int) $lk);
    }
    if (!$medOffer instanceof MedOffer) {
        $medOffer = Factory::createObject('medOffer');
    }
    $form = new base_form_Model($medOffer, DisplayClass::EDIT);
    $form->setAjaxForm('base_ajax_save_Controller');
    $form->addAction('&class=MedOffer');
    $form->setId('inputData');
    $formView = new base_form_View($form);
    $od->addContent($formView->showStartTag());
    $od->addContent($formView->showBody());
    $od->addContent($formView->showSubmit());
}

base_ui_Site::endMainContent($od);
base_ui_Site::displayBottom($od);

print $od->toString();
コード例 #22
0
ファイル: Model.php プロジェクト: kafruhs/fws
    /**
     * create the new MedOrder object and fill with data from MedOffer
     *
     * @param MedOffer  $medOffer
     * @param int       $amount
     *
     * @return MedOrder
     */
    private function _createMedOrder(MedOffer $medOffer, $amount)
    {
        $obj = Factory::createObject('medOrder');
        $obj['FK_medoffer'] = $medOffer->getLogicalKey();
        $obj['amount'] = $amount;
        $obj['price'] = $medOffer['price'] * (1 - $medOffer['rabatt'] / 100);
        $obj['sellerId'] = $medOffer['firstEditor'];
        $obj['pzn'] = $medOffer['pzn'];
        $obj['name'] = $medOffer['name'] . ' ' . $medOffer['amount'] . ' ' . $medOffer['dosage'];

        try {
            $obj->save();
        } catch (Exception $e) {
            $this->errors[] = $e->getMessage();
        }

        return $obj;
    }
コード例 #23
0
ファイル: TableList.php プロジェクト: kafruhs/fws
 public function getPageTitle()
 {
     $obj = Factory::createObject($this->getClass());
     return 'Suchergebnis: ' . $obj->getDisplayName();
 }
コード例 #24
0
ファイル: BaseObject.php プロジェクト: kafruhs/fws
 public function __construct($class, $filePath, $delimiter = ';', $hasHeader = true)
 {
     $this->obj = Factory::createObject($class);
     $this->loadData($filePath, $delimiter, $hasHeader);
 }