本文整理汇总了PHP中Options::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Options::model方法的具体用法?PHP Options::model怎么用?PHP Options::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$model = Options::model()->findByPk(1);
$this->site_name = $model->site_name;
$this->email = $model->email;
$this->top_news_count = $model->top_news_count;
$this->short_description_symbols = $model->short_description_symbols;
}
示例2: actionWeboptions
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'show' page.
*/
public function actionWeboptions()
{
if (isset($_POST['options_posted'])) {
User::updateOptionTemplate(User::optionsWebTemplate(), 0, 0);
$this->redirect(Yii::app()->request->baseUrl);
} else {
$this->render('weboptions', array('weboptions' => Options::model()->findAll('companyId=0 AND userId=0', array())));
}
}
示例3: optionsArrayToString
private function optionsArrayToString()
{
$criteria = new CDbCriteria();
$criteria->compare('companyId', $this->id);
$criteria->compare('userId', 0);
$options = Options::model()->findAll($criteria);
$returnString = '';
foreach ($options as $n => $option) {
$returnString .= $option->name . '=' . $option->datavalue . ";";
}
return $returnString;
}
示例4: actionIndex
/**
* Manages all models.
*/
public function actionIndex()
{
$model = Options::model()->findByPk(1);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Options'])) {
$model->attributes = $_POST['Options'];
if ($model->save()) {
Yii::app()->user->setFlash('success', Yii::t('main', 'Данные успешно сохранены!'));
$this->refresh();
} else {
Yii::app()->user->setFlash('error', Yii::t('main', 'Ошибка!'));
}
$this->refresh();
}
$this->render('index', array('model' => $model));
}
示例5: getElementsAndDynamicAttributes
/**
* getElementsAndDynamicAttributes
* @param array $componentData
* @access public
* @return array
*/
public function getElementsAndDynamicAttributes($componentData = [])
{
$elements = [];
$attributeArray = [];
$dynamicDataAttributes = [];
//$getFormCondition = 't.formId=:formId';
//$getFormParams = array(':formId' => 1);
$getForm = EvaluationElements::model()->findAll();
//$elements['title'] = "Components Form";
$elements['showErrorSummary'] = true;
$elements['showErrors'] = true;
$elements['errorSummaryHeader'] = Yii::app()->params['headerErrorSummary'];
$elements['errorSummaryFooter'] = Yii::app()->params['footerErrorSummary'];
$elements['activeForm']['id'] = "EvalForm";
$elements['activeForm']['enableClientValidation'] = true;
$elements['activeForm']['clientOptions'] = ['validateOnSubmit' => true];
//$elements['activeForm']['enableAjaxValidation'] = false;
$elements['activeForm']['class'] = 'CActiveForm';
//print_r($getForm); die();
$evalElements = $getForm;
$dataArray['getForm'] = $elements;
$inputType = 'text';
//$dynamicDataAttributes['frameworkId'] = 'frameworkId';
//$rules[] = ['frameworkId', 'required'];
$designData = FrameworkContext::model()->findAll(['condition' => 'userId=:userId', 'params' => [':userId' => Yii::app()->user->id]]);
$designItems = [];
// process the dropdown data into an array
foreach ($designData as $params) {
$designItems[$params->frameworkId] = $params->name;
}
$elements['elements'] = EvaluationHeader::getElements();
// add the dropdown items to the element
//$elements['elements']['frameworkId']['items'] = $designItems;
$elements['elements']['evaContext']['type'] = 'form';
//$elements['elements']['evaluationName']['layout'] = '{label} {input} {hint} {error}';
$rules = [];
$labels = [];
foreach ($evalElements as $element) {
//set the model attribute array
$attributeId = $element->inputName . "_" . $element->evalElementsId;
$dynamicDataAttributes[$attributeId] = '';
$validation = $element->required ? 'required' : 'safe';
$rules[] = [$attributeId, $validation];
if ($element->inputName == 'componentNo') {
$rules[] = [$attributeId, 'numerical'];
}
$highlightClass = "";
if (isset($attributeArray[$element->evalElementsId])) {
$highlightClass = "attributeHighlight";
}
$labels[$attributeId] = $element->label;
// add the elements to the CForm array
$elements['elements']['evaContext']['elements'][$attributeId] = ['label' => $element->label, 'required' => $element->required, 'type' => $element->inputType, 'class' => $highlightClass, 'title' => UtilModel::urlToLink($element->elementMetaData), 'data-field' => $element->evalElementsId];
// Add an image icon that will be displayed on the ui to show more info
$button = CHtml::image('', '', ['id' => 'moreInfoButton' . $element->evalElementsId, 'style' => 'cursor:pointer', 'class' => 'ui-icon ui-icon-info', 'title' => 'More Information', 'onClick' => '$("#moreInfoDialog").html($("#popupData' . $element->evalElementsId . '").html());$("#moreInfoDialog").dialog("open")']);
// Add the image icon and information to the layout/ui
// if (!empty($element->moreInfo) && !empty($element->url) && !empty($element->description)) {
// $elements['elements']['evaContext']['elements'][$attributeId]['layout'] = '{label}<div class="componentImagePopup">' . $button .
// '</div>{hint} {input}' . '<div id="popupData' . $element->evalElementsId . '" style="display:none">' . $element->moreInfo . '</div>' .
// '<div class="componentDataPopup">' . $element->description .
// ' <br/> <a href=' . $element->url . ' target=_blank>' . $element->url . '</a></div> {error}';
// }
// add the values to the form
if (!empty($componentData[$attributeId])) {
$elements['elements']['evaContext']['elements'][$attributeId]['value'] = $componentData[$attributeId]['value'];
}
// add the component name element value
if (!empty($componentData['evaluationName'])) {
$elements['elements']['evaContext']['elements']['evaluationName']['value'] = $componentData['evaluationName'];
}
// add the frameworkId element value
if (!empty($componentData['frameworkId'])) {
$elements['elements']['evaContext']['elements']['frameworkId']['value'] = $componentData['frameworkId'];
}
//add the dropdown parameters
if ($element->inputType == 'dropdownlist') {
$items = CHtml::listData(Options::model()->findAll(['condition' => 'elementId=:elementId', 'params' => [':elementId' => $element->evalElementsId]]), 'optionId', 'label');
// add the dropdown items to the element
$elements['elements']['evaContext']['elements'][$attributeId]['items'] = $items;
$elements['elements']['evaContext']['elements'][$attributeId]['prompt'] = 'Choose one';
}
if ($element->inputName == 'currentCost' || $element->inputName == 'budgetLimit') {
$elements['elements']['evaContext']['elements'][$attributeId]['class'] = 'update-able';
}
}
$elements['buttons'] = ['newEvaluation' => ['type' => 'submit', 'label' => 'Create evaluation context']];
$returnArray = ['elements' => $elements, 'dynamicDataAttributes' => $dynamicDataAttributes, 'labels' => $labels, 'rules' => $rules];
return $returnArray;
}
示例6: actionReport
/**
* Displays the requested report
*
*/
public function actionReport()
{
//throw(new Exception('just die'));
if ((isset($_POST['ShowReport']) || isset($_POST['DownloadPDF']) || isset($_POST['DownloadExcel'])) && isset($_POST['reportId'])) {
$this->_model = Report::model()->findbyPk($_POST['reportId']);
if ($this->_model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
//delete all the old report parameter values
ReportUserLastUsedParams::model()->dbConnection->createCommand('DELETE FROM ReportUserLastUsedParams WHERE reportId=' . $this->_model->id . ' AND userId=' . Yii::app()->user->id)->execute();
//build the Sql sats
$aliases = array();
$replacements = array();
$repParams = $this->_model->reportparameters;
$parameterValues = array();
$graphicFilename = "";
$title = "";
if (isset($repParams) && count($repParams) > 0) {
foreach ($repParams as $n => $repParam) {
//get the new parameter values
if ($repParam->dataType == 'HIDDEN_NO_SHOW_HEAD' || $repParam->dataType == 'HIDDEN_SHOW_HEAD') {
if (strlen($repParam->phpSecondaryInfo) > 0) {
eval($repParam->phpSecondaryInfo);
} else {
$defaultValue = $repParam->defaultValue;
if ($repParam->isDefaultPhp) {
eval($defaultValue);
}
}
$parameterValues[$n] = $defaultValue;
} else {
if (isset($_POST[$n])) {
if ($repParam->dataType == 'DATE') {
$parameterValues[$n] = User::parseDate($_POST[$n]);
} else {
$parameterValues[$n] = $_POST[$n];
}
if (strlen($title) == 0) {
$title = $_POST[$n];
}
$negateGraphicValues = false;
if ($repParam->name == 'Negate values for graphics') {
$negateGraphicValues = (int) $_POST[$n];
}
//save the parameter values
$saveLast = new ReportUserLastUsedParams();
$saveLast->reportId = $this->_model->id;
$saveLast->userId = Yii::app()->user->id;
$saveLast->paramId = $n;
$saveLast->LastUsedValue = $parameterValues[$n];
$saveLast->save();
}
}
//get the aliases
if (strlen($repParam->alias) > 0) {
$aliases[] = $repParam->alias;
if ($repParam->dataType == 'HIDDEN_NO_SHOW_HEAD' || $repParam->dataType == 'HIDDEN_SHOW_HEAD') {
$defaultValue = $repParam->defaultValue;
if ($repParam->isDefaultPhp) {
eval($defaultValue);
}
$replacements[] = $defaultValue;
} else {
if ($repParam->dataType == 'DATE') {
$replacements[] = User::parseDate($_POST[$n]);
} else {
$replacements[] = $_POST[$n];
}
}
if ($repParam->alias == '{ShowGraph}' && strlen($_POST[$n]) > 0) {
$graphicFilename = $_POST[$n];
}
}
}
}
$sqlSelect = str_replace($aliases, $replacements, $this->_model->selectSql);
// var_dump($aliases);
// var_dump($replacements);
//echo $sqlSelect.'<br><br>';
// echo $sqlSelect; die();
//execute the Sql sats
//Yii::log($sqlSelect, CLogger::LEVEL_INFO, 'system.web.CController');
$command = Report::model()->dbConnection->createCommand($sqlSelect);
try {
$reader = $command->query();
//foreach($reader as $row)print_r($row);
//die();
} catch (Exception $e) {
echo '<h2>Died on Sql execution</h2>' . $sqlSelect;
throw $e;
}
$imageFileNames = array();
$imageFilePaths = array();
if (strlen($graphicFilename) > 0) {
$images = $this->readXmlGraphicFile($graphicFilename, false, $reader, $title, $negateGraphicValues, $imageFileNames);
$imageFileNames = $images[1];
//.........这里部分代码省略.........
示例7: setOption
public static function setOption($name, $val)
{
if ($name) {
$param = Options::model()->findByAttributes(['key' => $name]);
if ($param) {
$param->value = $val;
$param->update();
return true;
} else {
$param = new Options();
$param->key = $name;
$param->value = $val;
$param->save();
return true;
}
} else {
return false;
}
}
示例8: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Options the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Options::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例9: createUrl
} else {
$(like).val(0);
}
console.log($(like).val());
}
</script>
</tbody>
</table>
</div><!-- form -->
</div>
</div>
<div class="row">
<div class="col-lg-12">
<?php
$option = Options::model()->findAll(array('limit' => 1));
$url;
if (yii::app()->user->isUser()) {
if ($option[0]->id > 3) {
$url = createUrl('options/optionView', array('id' => $option[0]->id));
} else {
$url = createUrl('options/optionView', array('id' => $option[0]->id));
}
} elseif (yii::app()->user->isFranchiseAdmin()) {
if ($option[0]->id > 3) {
$url = createUrl('options/optionsView', array('options_num' => $option[0]->id, 'custom' => 1));
} else {
$url = createUrl('options/optionsView', array('options_num' => $option[0]->id));
}
} else {
$url = createUrl('customer/list');
示例10: actionDownloadPdf
public function actionDownloadPdf($id)
{
$cusUser = Customer::model()->findByPk($id);
if (!$cusUser) {
throw new CHttpException(403, 'Customer not exists');
}
$franchise_admin = User::model()->find(" franchise = " . $cusUser->franchise . " and role_id=3");
$pdf_content = PdfContentFranchise::model()->findByAttributes(array('cus_id' => $id, 'isactive' => 1, 'type' => 2));
if (!$pdf_content) {
$pdf_content = PdfContent::model()->findByAttributes(array('type' => 2));
}
$params = array();
$offers = Options::model()->findByPk($cusUser->option_id);
if (!$offers) {
$offers = CustomOptionsId::model()->findByPk($cusUser->option_id);
}
$params['options'][] = $offers;
$params['lunchMenu'] = $cusUser->lunches;
$params['breakfasts'] = $cusUser->breakfasts;
$params['indusFoods'] = $cusUser->indusFoods;
$params['sundries'] = $cusUser->sundries;
$params['sandwiches'] = $cusUser->sandwiches;
$params['hotfood'] = $cusUser->hotFoods;
$params['magicSpoolsAns'] = $cusUser->magicSpoolsAns;
$selProd = SelProducts::model()->findAll(array("condition" => "cus_id =" . $id, "order" => "product_id asc"));
$params['selproducts'] = array();
foreach ($selProd as $selp) {
$product = Product::model()->findByPk($selp->product_id);
$params['selproducts'][] = array_merge($product->attributes, $selp->attributes);
}
$this->layout = '//decorators/empty';
$html2pdf = Yii::app()->ePdf->HTML2PDF();
///////////////////////////////////// menu container started
$container = array();
foreach ($params as $param) {
foreach ($param as $p) {
$container[] = $p;
}
}
$div_array = array_chunk($container, 200);
$showTitle = 1;
foreach ($div_array as $array) {
$html2pdf->WriteHTML($this->renderPartial('//decorators/pdf_no_h_f', array('params' => $array, 'cusUser' => $cusUser, 'showTitle' => $showTitle, 'franchise_admin' => $franchise_admin, 'pdf_content' => $pdf_content), true));
$showTitle = 0;
}
if (Yii::app()->session['User_mail']) {
$html2pdf->Output(dirname(__FILE__) . '/../../pdf/test_xxxx.pdf', 'F');
$message = "\n You Will find an pdf attachment in this mail which contain detail of all the menues and items selected \n by you.\n ";
$subject = "\n Customer Solutions Iform Pdf Form\n ";
$mail_to = array();
if ($franchise_admin->email) {
$mail_to[] = $franchise_admin->email;
}
// if ($cusUser->email)
// $mail_to[] = $cusUser->email;
if ($cusUser->attendee0->email) {
$mail_to[] = $cusUser->attendee0->email;
}
$this->mail_attachment('Jasper Franchise.pdf', 'FILEPATH', $mail_to, 'franchise@admin.com', 'Jaspers', 'noreply@jasperfranchise.co.uk', $subject, $message);
} else {
$html2pdf->Output('jasper_franchise.pdf', 'D');
}
unset(Yii::app()->session['User_mail']);
Yii::app()->session['email_sent'] = $cusUser->id;
$this->redirect(array('site/index'));
}
示例11: actionGetInputTypeOpts
/**
* actionGetInputTypeOpts
*
* @access public
* @return void
*/
public function actionGetInputTypeOpts()
{
$optArray = array();
if (!empty($_GET['subFormId'])) {
$subFormId = $_GET['subFormId'];
$options = Options::model()->findAll(array("condition" => "componentId = {$subFormId}", 'select' => 'optionId, label'));
if (!empty($options)) {
foreach ($options as $opt) {
$optArray[] = $opt->getAttributes();
}
}
}
echo json_encode(array("aaData" => $optArray));
return;
}
示例12: actionOptionsEditView
public function actionOptionsEditView()
{
$customer = Customer::model()->findByPk(getCurCusId());
if (isset($_POST['option'])) {
$cus = Customer::Model()->findByPk(getCurCusId());
$cus->option_id = $_POST['option'];
$cus->save();
$this->redirect(array('site/index'));
}
if (isset($_GET['options_num'])) {
$value = intval(isset($_GET['options_num']) ? $_GET['options_num'] : "0");
$model = Options::model()->findByPk($value);
if ($model === NULL || empty($model)) {
$model = array('offer_msg' => "Sorry, Selected offer is not available");
}
} else {
$model = array('offer_msg' => "Please choose Offers");
}
$criteria = new CDbCriteria();
$criteria->compare('franchise', Yii::app()->user->franchise);
$customers = Customer::model()->findAll($criteria);
$customerlist = CHtml::listData($customers, 'id', 'name');
$this->render("optioneditviews", array('model' => $model, 'customers' => $customerlist, 'id' => $customer->option_id));
}
示例13: updateOptionTemplate
public static function updateOptionTemplate($options, $id, $companyId, $updateAdminOptions = true)
{
$webapp = Yii::app()->user;
foreach ($options as $key => $option) {
if (($updateAdminOptions || $option[5] == 'false') && $option[3] == 'false') {
$foundOption = Options::model()->find('name=:name AND userId=:id AND companyId=:compid', array(':name' => $key, ':id' => $id, ':compid' => $companyId));
if ($foundOption === null) {
$createOption = new Options();
$createOption->name = $key;
$createOption->userId = $id;
$createOption->companyId = $companyId;
$foundOption = $createOption;
}
switch ($option[0]) {
case 'STRING':
case 'DROP_DOWN_LIST':
case 'INTEGER':
case 'FLOAT':
case 'DATE':
$foundOption->datavalue = $_POST['option_' . $foundOption->name];
break;
case 'BOOLEAN':
$foundOption->datavalue = isset($_POST['option_' . $foundOption->name]) && $_POST['option_' . $foundOption->name] == 1 ? 'true' : 'false';
break;
}
if ($foundOption->name == 'NonStandardNumberDecimalFormat' || $foundOption->name == 'NonStandardNumberDecimalFormat') {
if (Yii::app()->user->getState('allowAdmin')) {
$foundOption->save();
}
} else {
$foundOption->save();
}
if ($id == $webapp->id || $id == 0) {
$webapp->setState($key, User::convertOptionToObject($foundOption->datavalue, $option));
}
}
}
}
示例14: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'show' page.
*/
public function actionUpdate()
{
$model = $this->loadCompany();
if (isset($_POST['Company'])) {
$modelBeforeChange = $model->toString();
$model->attributes = $_POST['Company'];
if ($model->save()) {
User::updateOptionTemplate(User::optionsCompanyTemplate(), 0, $model->id);
$stringModel = $model->toString();
if ($modelBeforeChange != $stringModel) {
ChangeLog::addLog('UPDATE', 'Company', 'BEFORE<br />' . $modelBeforeChange . '<br />AFTER<br />' . $stringModel);
}
$this->redirect(array('admin', 'id' => $model->id));
}
}
User::setOptionStatesAndControlTable(false, false, Yii::app()->user, User::optionsCompanyTemplate(), $model->id, 0);
$criteria = new CDbCriteria();
$criteria->compare('companyId', $model->id);
$criteria->compare('userId', 0);
$options = Options::model()->findAll($criteria);
$this->render('update', array('model' => $model, 'options' => $options));
}
示例15: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'show' page.
*/
public function actionUpdate()
{
$model = $this->loadUser();
if (isset($_POST['User'])) {
$oldPassword = $model->password;
$modelBeforeChange = $model->toString();
$model->attributes = $_POST['User'];
//salt must contain something
if (!isset($model->salt) || strlen($model->salt) == 0) {
$model->salt = hash('sha1', uniqid(rand(), true));
//since the salt has changed, We must have a new password. Force it if it is not changed
if (strlen($model->password) == 0 && strlen($model->confirmPassword == 0)) {
//this forces the entry of a new password
unset($oldPassword);
}
}
//only check the password if they have entered something. Blank password is ignored.
if (strlen($model->password) == 0 && strlen($model->confirmPassword == 0)) {
$model->password = $oldPassword;
$model->confirmPassword = $oldPassword;
} else {
$model->password = hash('sha1', $model->password . $model->salt);
$model->confirmPassword = hash('sha1', $model->confirmPassword . $model->salt);
}
if ($model->save()) {
if (Yii::app()->user->getState('allowAdmin')) {
//remove all companies for this user
User::model()->dbConnection->createCommand("DELETE FROM CompanyUser WHERE userId={$model->id}")->execute();
$companies = array();
if (isset($_POST['companies'])) {
$companies = $_POST['companies'];
}
//must remove all options for unchosen companies.
$beforeCompanies = $model->companies;
foreach ($beforeCompanies as $beforeComp) {
$foundCompany = false;
foreach ($companies as $comp) {
if ($comp == $beforeComp->id) {
$foundCompany = true;
break;
}
}
if (!$foundCompany) {
//company no longer selected. Delete all options
User::model()->dbConnection->createCommand("INSERT INTO CompanyUser (userId, companyId) VALUES ({$model->id},{$beforeComp->id})")->execute();
}
}
$foundCurrentCompany = false;
$foundSelectedCompany = false;
//re-add the selected companies
foreach ($companies as $comp) {
User::model()->dbConnection->createCommand("INSERT INTO CompanyUser (userId, companyId) VALUES ({$model->id},{$comp})")->execute();
if ($model->selectedCompanyId == $comp) {
$foundCurrentCompany = true;
}
if ($_POST['companyForOptionsBeforeChange'] == $comp) {
$foundSelectedCompany = true;
}
}
if (!$foundCurrentCompany) {
//they have remove the currently selected company. We must remove it as being selected
$model->selectedCompanyId = 0;
$model->selectedPeriodId = 0;
$model->confirmPassword = $model->password;
$model->save();
if (Yii::app()->user->id == $_GET['id']) {
$model->setStates();
}
}
}
//do the options
$this->setOptionsByTemplate(false);
//user options first
User::updateOptionTemplate(User::optionsUserTemplate(), $model->id, 0, Yii::app()->user->getState('allowAdmin'));
//company options, only if admin
if (!isset($_POST['save']) && Yii::app()->user->getState('allowAdmin')) {
//we must set all companies to the template chosen
foreach ($companies as $comp) {
User::updateOptionTemplate(User::optionsCompanyUserTemplate(), $model->id, $comp);
}
} elseif (isset($foundSelectedCompany) && $foundSelectedCompany && Yii::app()->user->getState('allowAdmin')) {
//no template chosen. Just update the visible options for the selected company
$model->updateOptionTemplate($model->optionsCompanyUserTemplate(), $model->id, $_POST['companyForOptionsBeforeChange']);
}
$stringModel = $model->toString();
if ($modelBeforeChange != $stringModel) {
ChangeLog::addLog('UPDATE', 'Account', 'BEFORE<br />' . $modelBeforeChange . '<br />AFTER<br />' . $stringModel);
}
//we need to reload this user to get all the updates in the companies.
$this->_model = User::model()->findbyPk(isset($id) && $id !== null ? $id : $_GET['id']);
$model = $this->_model;
// $this->redirect(array('update','id'=>$model->id));
} else {
unset($this->_model->password);
unset($this->_model->confirmPassword);
}
//.........这里部分代码省略.........