Exemplo n.º 1
0
 public static function validateMultiple($models, $attributes = null, $loadInput = true)
 {
     $result = array();
     if (!is_array($models)) {
         $models = array($models);
     }
     foreach ($models as $i => $model) {
         if (is_array($_POST[get_class($model)])) {
             foreach ($_POST[get_class($model)] as $j => $m) {
                 if ($loadInput && isset($_POST[get_class($model)][$j])) {
                     $model->attributes = $_POST[get_class($model)][$j];
                 }
                 $model->validate($attributes);
                 foreach ($model->getErrors() as $attribute => $errors) {
                     $result[CHtml::activeId($model, '[' . $j . ']' . $attribute)] = $errors;
                 }
             }
         } else {
             if ($loadInput && isset($_POST[get_class($model)])) {
                 $model->attributes = $_POST[get_class($model)];
             }
             $model->validate($attributes);
             foreach ($model->getErrors() as $attribute => $errors) {
                 $result[CHtml::activeId($model, $attribute)] = $errors;
             }
         }
     }
     return function_exists('json_encode') ? json_encode($result) : CJSON::encode($result);
 }
Exemplo n.º 2
0
 public function getAdminForm()
 {
     if (empty($this->origincountry)) {
         $this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
     }
     return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'mode' => array('type' => 'dropdownlist', 'items' => array('UPS' => 'Domestic US UPS Mode', 'IUPS' => 'IUPS International UPS Mode')), 'username' => array('type' => 'text', 'maxlength' => 64), 'password' => array('type' => 'text', 'maxlength' => 64), 'accesskey' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => ups::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'package' => array('type' => 'dropdownlist', 'items' => ups::$package_types), 'ratecode' => array('type' => 'dropdownlist', 'items' => ups::$rate_types), 'customerclassification' => array('type' => 'dropdownlist', 'items' => array('04' => 'Retail', '03' => 'Occasional', '01' => 'Wholesale')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
 }
Exemplo n.º 3
0
 /**
  * @param array $widgetOptions Widget options.
  * @covers ::run
  * @dataProvider testRun_FieldRendering_Provider
  */
 public function testRun_FieldRendering($widgetOptions)
 {
     $widget = $this->makeWidget();
     foreach ($widgetOptions as $option => $value) {
         $widget->{$option} = $value;
     }
     $widgetOutput = $this->runAndCapture($widget);
     $value = isset($widgetOptions['model']) ? $widgetOptions['model']->login : $widgetOptions['value'];
     if (isset($widgetOptions['model'])) {
         $name = CHtml::activeName($widgetOptions['model'], $widgetOptions['attribute']);
     } elseif (isset($widgetOptions['htmlOptions']['name'])) {
         $name = $widgetOptions['htmlOptions']['name'];
     } else {
         $name = $widgetOptions['name'];
     }
     if (isset($widgetOptions['model'])) {
         $id = CHtml::activeId($widgetOptions['model'], $widgetOptions['attribute']);
     } elseif (isset($widgetOptions['htmlOptions']['id'])) {
         $id = $widgetOptions['htmlOptions']['id'];
     } else {
         $id = CHtml::getIdByName($widgetOptions['name']);
     }
     if ($widgetOptions['type'] == Select2::TYPE_TEXT) {
         $this->assertTag(['tag' => 'input', 'attributes' => ['type' => 'text', 'name' => $name, 'id' => $id, 'value' => $value, 'class' => 'baz']], $widgetOutput);
     } else {
         $this->assertTag(['tag' => 'select', 'attributes' => ['name' => $name, 'id' => $id, 'class' => 'baz']], $widgetOutput);
         $this->assertTag(['tag' => 'option', 'parent' => ['tag' => 'select'], 'attributes' => ['selected' => 'selected', 'value' => $value]], $widgetOutput);
     }
 }
Exemplo n.º 4
0
 /**
  * Capture the latitude and longitude of the marker to a model.
  * 
  * @param CModel $model Model object
  * @param string $lat Attribute name for latitude
  * @param string $lng Attribute name for longitude
  * @param array $options Options to set :<ul>
  * <li>'visible' - show the input fields
  * <li>'nocallback' - do not update on callback
  * <li>'nodragend' - do not update on dragend
  * <li>'drag' - update on drag
  * </ul>
  */
 public function capturePosition(CModel $model, $lat, $lng, array $options = array())
 {
     // field options
     if (in_array('visible', $options)) {
         echo CHtml::activeLabelEx($model, $lat), CHtml::activeTextField($model, $lat);
         echo '<br>';
         echo CHtml::activeLabelEx($model, $lng), CHtml::activeTextField($model, $lng);
     } else {
         echo CHtml::activeHiddenField($model, $lat), CHtml::activeHiddenField($model, $lng);
     }
     $latId = CHtml::activeId($model, $lat);
     $lngId = CHtml::activeId($model, $lng);
     // update function
     $jsFunction = "function captureMarkerPosition(marker){\$('#{$latId}').val(marker.getPosition().lat());\$('#{$lngId}').val(marker.getPosition().lng());}";
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#capturePosition', $jsFunction, CClientScript::POS_END);
     // event options
     if (!in_array('nocallback', $options)) {
         $this->addCallback('function(result){captureMarkerPosition(result);}');
     }
     if (!in_array('nodragend', $options)) {
         $this->addEvent('dragend', 'function(result){captureMarkerPosition(result);}');
     }
     if (in_array('drag', $options)) {
         $this->addEvent('drag', 'function(result){captureMarkerPosition(result);}');
     }
     $this->addEvent('position_changed', 'function(result){captureMarkerPosition(result);}');
 }
Exemplo n.º 5
0
 public function getAdminForm()
 {
     if (empty($this->origincountry)) {
         $this->origincountry = (int) _xls_get_conf('DEFAULT_COUNTRY', 224);
     }
     return array('title' => 'Note: You can ' . CHtml::link('Set Product Restrictions', '#', array('class' => 'basic', 'id' => get_class($this))) . ' for this module.', 'elements' => array('label' => array('type' => 'text', 'maxlength' => 64), 'accnumber' => array('type' => 'text', 'maxlength' => 64), 'meternumber' => array('type' => 'text', 'maxlength' => 64), 'securitycode' => array('type' => 'text', 'maxlength' => 64), 'authkey' => array('type' => 'text', 'maxlength' => 64), 'originadde' => array('type' => 'text', 'maxlength' => 64), 'origincity' => array('type' => 'text', 'maxlength' => 64), 'originpostcode' => array('type' => 'text', 'maxlength' => 64), 'origincountry' => array('type' => 'dropdownlist', 'items' => CHtml::listData(Country::model()->findAllByAttributes(array('active' => 1), array('order' => 'sort_order,country')), 'id', 'country'), 'ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl('ajax/getstates'), 'data' => 'js:{"' . 'country_id' . '": $("#' . CHtml::activeId($this, 'origincountry') . ' option:selected").val()}', 'update' => '#' . CHtml::activeId($this, 'originstate'))), 'originstate' => array('type' => 'dropdownlist', 'items' => CHtml::listData(State::model()->findAllByAttributes(array('country_id' => $this->origincountry, 'active' => 1), array('order' => 'sort_order,state')), 'id', 'code')), 'offerservices' => array('type' => 'checkboxlist', 'items' => fedex::$service_types, 'separator' => '', 'template' => '<div class="offerservices">{input} {label}</div>', 'label' => 'Offer these services<br><a onclick="selectall()">Select All</a><br><a onclick="selectnone()">Select None</a><br>'), 'packaging' => array('type' => 'dropdownlist', 'items' => array('YOUR_PACKAGING' => 'Your packaging', 'FEDEX_BOX' => 'FedEx Box', 'FEDEX_PAK' => 'FedEx Pak', 'FEDEX_TUBE' => 'FedEx Tube')), 'ratetype' => array('type' => 'dropdownlist', 'items' => array('RATED_LIST' => 'List Rates', 'RATED_ACCOUNT' => 'Negotiated rates')), 'customs' => array('type' => 'dropdownlist', 'items' => array('CLEARANCEFEE' => 'FedEx Handles Customs Clearance', 'NOCHARGE' => 'My store handles Customs Clearance')), 'restrictcountry' => array('type' => 'dropdownlist', 'items' => Country::getAdminRestrictionList(true)), 'markup' => array('type' => 'text', 'maxlength' => 4), 'product' => array('type' => 'text', 'maxlength' => 64)));
 }
Exemplo n.º 6
0
 public function init()
 {
     $publishFolder = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets', false, -1, true);
     Yii::app()->clientScript->packages['_fileuploader'] = array('baseUrl' => $publishFolder, 'js' => array('js/vendor/jquery.ui.widget.js', 'js/jquery.iframe-transport.js', 'js/jquery.fileupload.js', 'js/jquery.fileupload-process.js'), 'css' => array('css/jquery.fileupload.css', 'css/jquery.fileupload-ui'), 'depends' => array('jquery', 'glyphicons'));
     Yii::app()->clientScript->registerPackage('_fileuploader');
     $this->render('index', array('controlId' => $this->id . '_uploader', 'uploadName' => $this->hasModel() ? CHtml::activeName($this->model, $this->attribute) : $this->name, 'uploadUrl' => CHtml::normalizeUrl($this->url), 'uploadId' => $this->hasModel() ? CHtml::activeId($this->model, $this->attribute) : "{$this->id}_{$this->name}", 'publicUrl' => $publishFolder));
 }
Exemplo n.º 7
0
 public function init()
 {
     $this->options = array_merge($this->options, array('autoFocus' => true, 'showAnim' => 'fold'));
     $this->autoCompleteHtmlOptions = array_merge($this->autoCompleteHtmlOptions, array('name' => $this->returnId ? str_replace('[', '_disabled[', CHtml::activeName($this->model, $this->attribute)) : CHtml::activeName($this->model, $this->attribute), 'id' => CHtml::activeId($this->model, $this->attribute), 'value' => $this->value));
     if ($this->returnId) {
         $this->options = array_merge($this->options, array('select' => "js:function(event,ui){\n\t\t\t\t\t\t\t\t\$('input#'+\$(this).attr('id')+'[type=hidden]').attr('value',ui.item.id);\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}"));
     }
 }
Exemplo n.º 8
0
Arquivo: mics.php Projeto: hung5s/yap
/**
 * Format errors of model's attributes in JSON
 * to use for CActiveForm with validateOnSubmit
 *
 * @param mixed $model
 */
function getJsonErrors($model)
{
    $errors = array();
    foreach ($model->getErrors() as $attribute => $errs) {
        $errors[CHtml::activeId($model, $attribute)] = $errs;
    }
    return CJSON::encode($errors);
}
 /**
  * Initializes the widget.
  * This method will publish jQuery and miniColors plugin assets if necessary.
  * @return void
  */
 public function init()
 {
     $activeId = CHtml::activeId($this->model, $this->attribute);
     self::registerScriptFiles();
     $options = CJavaScript::encode($this->options);
     $cs = Yii::app()->getClientScript();
     $cs->registerScript('miniColors-' . $activeId, '$("#' . $activeId . '").miniColors(' . $options . ');');
 }
Exemplo n.º 10
0
 /**
  * Capture the map's zoom level to a field
  * 
  * @param CModel $model Model containing the attribute
  * @param string $attribute Name of the model's attribute
  * @param boolean $generate Whether to generate the field
  * @param array $htmlOptions HTML options for the field
  */
 public function captureZoom(CModel $model, $attribute, $generate = true, array $htmlOptions = array())
 {
     if ($generate) {
         echo CHtml::activeHiddenField($model, $attribute, $htmlOptions);
     }
     $attId = CHtml::activeId($model, $attribute);
     $this->addEvent('zoom_changed', "function(map){\$('#{$attId}').val(map.getZoom());}");
 }
Exemplo n.º 11
0
 protected function resolveId($model, $attribute)
 {
     $id = CHtml::activeId($model, $attribute);
     if ($this->inputPrefixData == null) {
         return $id;
     }
     $inputIdPrefix = Element::resolveInputIdPrefixIntoString($this->inputPrefixData);
     return str_replace(get_class($model), $inputIdPrefix, $id);
 }
Exemplo n.º 12
0
 public function init()
 {
     $this->options['onSubmit'] = 'js:function(hsb,hex,rgb,el) { $(el).val(hex); $(el).ColorPickerHide(); }';
     $options = CJavaScript::encode($this->options);
     $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'source';
     $this->baseUrl = Yii::app()->getAssetManager()->publish($dir);
     $cs = Yii::app()->getClientScript();
     $cs->registerScriptFile($this->baseUrl . '/js/colorpicker.js');
     $cs->registerCssFile($this->baseUrl . '/css/colorpicker.css');
     $activeId = CHtml::activeId($this->model, $this->attribute);
     $cs->registerScript($activeId . '-Script', '$("#' . $activeId . '").ColorPicker(' . $options . ');');
 }
 /**
  * Initializes the widget.
  * This method will publish jQuery and miniColors plugin assets if necessary.
  * @return void
  */
 public function init()
 {
     $activeId = CHtml::activeId($this->model, $this->attribute);
     $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'source';
     $baseUrl = Yii::app()->getAssetManager()->publish($dir);
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('jquery');
     $cs->registerScriptFile($baseUrl . '/jquery.miniColors.min.js');
     $cs->registerCssFile($baseUrl . '/jquery.miniColors.css');
     $options = CJavaScript::encode($this->options);
     $cs->registerScript('miniColors-' . $activeId, '$("#' . $activeId . '").miniColors(' . $options . ');');
 }
Exemplo n.º 14
0
 /**
  * Displays the first validation error for a model attribute.
  * @param CModel $model the data model
  * @param string $attribute the attribute name
  * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
  * @param boolean $enableAjaxValidation whether to enable AJAX validation for the specified attribute.
  * @param boolean $enableClientValidation whether to enable client-side validation for the specified attribute.
  * @return string the validation result (error display or success message).
  */
 public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true)
 {
     if (!$this->enableAjaxValidation) {
         $enableAjaxValidation = false;
     }
     if (!$this->enableClientValidation) {
         $enableClientValidation = false;
     }
     if (!$enableAjaxValidation && !$enableClientValidation) {
         return TbHtml::error($model, $attribute, $htmlOptions);
     }
     $id = CHtml::activeId($model, $attribute);
     $inputID = TbArray::getValue('inputID', $htmlOptions, $id);
     unset($htmlOptions['inputID']);
     TbArray::defaultValue('id', $inputID . '_em_', $htmlOptions);
     $option = array('id' => $id, 'inputID' => $inputID, 'errorID' => $htmlOptions['id'], 'model' => get_class($model), 'name' => $attribute, 'enableAjaxValidation' => $enableAjaxValidation, 'inputContainer' => 'div.form-group', 'errorCssClass' => 'has-error', 'successCssClass' => 'has-success');
     $optionNames = array('validationDelay', 'validateOnChange', 'validateOnType', 'hideErrorMessage', 'inputContainer', 'errorCssClass', 'successCssClass', 'validatingCssClass', 'beforeValidateAttribute', 'afterValidateAttribute');
     foreach ($optionNames as $name) {
         if (isset($htmlOptions[$name])) {
             $option[$name] = TbArray::popValue($name, $htmlOptions);
         }
     }
     if ($model instanceof CActiveRecord && !$model->isNewRecord) {
         $option['status'] = 1;
     }
     if ($enableClientValidation) {
         $validators = TbArray::getValue('clientValidation', $htmlOptions, array());
         $attributeName = $attribute;
         if (($pos = strrpos($attribute, ']')) !== false && $pos !== strlen($attribute) - 1) {
             $attributeName = substr($attribute, $pos + 1);
         }
         /** @var CValidator $validator */
         foreach ($model->getValidators($attributeName) as $validator) {
             if ($validator->enableClientValidation) {
                 if (($js = $validator->clientValidateAttribute($model, $attributeName)) != '') {
                     $validators[] = $js;
                 }
             }
         }
         if ($validators !== array()) {
             $validators = implode("\n", $validators);
             $option['clientValidation'] = "js:function(value, messages, attribute) {\n{$validators}\n}";
         }
     }
     $html = TbHtml::error($model, $attribute, $htmlOptions);
     if ($html === '') {
         $htmlOptions['type'] = $this->helpType;
         TbHtml::addCssStyle('display:none', $htmlOptions);
         $html = TbHtml::help('', $htmlOptions);
     }
     $this->attributes[$inputID] = $option;
     return $html;
 }
Exemplo n.º 15
0
 /** Retrieves encoded array with errors for ajax form validation
  * @param bool $encodeForAjax
  * @return array|string
  */
 public function getErrorsForForm($encodeForAjax = TRUE)
 {
     $result = array();
     foreach ($this->getErrors() as $attribute => $errors) {
         $result[CHtml::activeId($this, $attribute)] = $errors;
     }
     if ($encodeForAjax) {
         return function_exists('json_encode') ? json_encode($result) : CJSON::encode($result);
     } else {
         return $result;
     }
 }
Exemplo n.º 16
0
 public static function validateObj($models, $attributes = null, $loadInput = true)
 {
     $result = array();
     if (!is_array($models)) {
         $models = array($models);
     }
     foreach ($models as $model) {
         if ($loadInput && isset($_POST[get_class($model)])) {
             $model->attributes = $_POST[get_class($model)];
         }
         $model->validate($attributes);
         foreach ($model->getErrors() as $attribute => $errors) {
             $result[CHtml::activeId($model, $attribute)] = $errors;
         }
     }
     return $result;
 }
Exemplo n.º 17
0
    public function run()
    {
        parent::run();
        $cs = Yii::app()->clientScript;
        $this->assetUrl = $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets');
        $cs->registerCssFile('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
        $cs->registerCssFile($assets . '/css/wseditcartmodal.css');
        $this->widget('ext.jquery-history-js.jqueryHistoryJs');
        Yii::app()->clientScript->registerScript('instantiate checkout', sprintf('$(document).ready(function () {
					checkout = new Checkout(%s);
				});', Checkout::getCheckoutJSOptions()), CClientScript::POS_HEAD);
        Yii::app()->clientScript->registerScript('instantiate wsEditCartModal', sprintf('$(document).ready(function () {
					wsEditCartModal = new WsEditCartModal(%s);
					wsEditCartModal.checkout = checkout;
				});', CJSON::encode(array('checkoutUrl' => Yii::app()->createUrl('checkout'), 'updateCartItemEndpoint' => Yii::app()->createUrl('cart/updatecartitem'), 'csrfToken' => Yii::app()->request->csrfToken, 'cartId' => CHtml::activeId('EditCart', 'promoCode'), 'invalidQtyMessage' => Yii::t('checkout', '<strong>Only {qty} are available at this time.</strong><br> If you’d like ' . 'to order more please return at a later time or contact us.')))), CClientScript::POS_HEAD);
        $this->render('editcartmodal');
    }
Exemplo n.º 18
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->hasModel() && $this->name === null) {
         throw new CException("Either 'name', or 'model' and 'attribute' properties must be specified.");
     }
     if (!isset($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = $this->hasModel() ? CHtml::activeId($this->model, $this->attribute) : $this->getId();
     }
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     $this->htmlOptions = TbArray::merge($this->asDataAttributes($this->pluginOptions), $this->htmlOptions);
     $this->pluginOptions = false;
     if ($this->hasModel()) {
         $this->htmlOptions['data-name'] = CHtml::activeId($this->model, $this->attribute);
         $this->htmlOptions['data-value'] = CHtml::value($this->model, $this->attribute);
     } else {
         $this->htmlOptions['data-name'] = $this->name;
         $this->htmlOptions['data-value'] = $this->value;
     }
 }
 public function actionUploadFromUrl()
 {
     $form = new ImportImageFromUrlForm();
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'image-import-form') {
         $errors = ZurmoActiveForm::validate($form);
         if ($form->hasErrors()) {
             echo $errors;
             Yii::app()->end();
         }
     }
     if (isset($_POST['ImportImageFromUrlForm'])) {
         $url = $_POST['ImportImageFromUrlForm']['url'];
         $fileUploadData = ImageFileModelUtil::importFromUrl($url);
         if (isset($fileUploadData['error'])) {
             $result[CHtml::activeId($form, 'url')] = array($fileUploadData['error']);
             echo CJSON::encode($result);
             Yii::app()->end();
         } else {
             echo CJSON::encode($fileUploadData);
         }
     }
 }
Exemplo n.º 20
0
 /**
  * get validation errors
  * 
  * @param array $related list of related models names
  * @return array the errors list in yii format
  */
 public function getErrors($related = array())
 {
     $errorList = array();
     $owner = $this->getOwner();
     //get owner model error list
     foreach ($owner->getErrors() as $attribute => $errors) {
         $errorList[CHtml::activeId($owner, $attribute)] = $errors;
     }
     //get related models error list
     foreach ($related as $name) {
         if (is_array($owner->{$name})) {
             foreach ($owner->{$name} as $i => $rel) {
                 foreach ($rel->getErrors() as $attribute => $errors) {
                     $errorList[CHtml::activeId($rel, '[' . $i . ']' . $attribute)] = $errors;
                 }
             }
         } else {
             foreach ($owner->{$name}->getErrors() as $attribute => $errors) {
                 $errorList[CHtml::activeId($owner->{$name}, $attribute)] = $errors;
             }
         }
     }
     return $errorList;
 }
Exemplo n.º 21
0
				<?php 
echo $form->textField($model, 'city');
?>
				<?php 
echo $form->error($model, 'city');
?>
			</div>
		</div>

		<div class="row-fluid">
			<div class="span5">
				<?php 
echo $form->labelEx($model, 'country_id');
?>
				<?php 
echo $form->dropDownList($model, 'country_id', $checkout->getCountries(), array('ajax' => array('type' => 'POST', 'url' => CController::createUrl('cart/getdestinationstates'), 'update' => '#' . CHtml::activeId($model, 'state_id'), 'data' => 'js:{"country_id": $("#' . CHtml::activeId($model, 'country_id') . ' option:selected").val()}')));
?>
				<?php 
echo $form->error($model, 'country_id');
?>
			</div>
		</div>

		<div class="row-fluid">
			<div id="state_id" class="span5">
				<?php 
echo $form->labelEx($model, 'state_id');
?>
				<?php 
echo $form->dropDownList($model, 'state_id', $checkout->getStates('myaccount', $model->country_id), array('prompt' => '--'));
?>
Exemplo n.º 22
0
                                                        
											},
											{
												xtype:'panel',
												flex:.25,
												height:150,
												title:'SERVICE CHARGES',
												layout:'absolute',
												items:[
													{
														xtype:'textfield',
														labelWidth:120,
														fieldLabel:'1. Service Charge',
														anchor:'95%',
														id:<?php 
echo CJSON::encode(CHtml::activeId($shipment, 'shipping_charges'));
?>
,
														name:<?php 
echo CJSON::encode(CHtml::activeName($shipment, 'shipping_charges'));
?>
,
														value:<?php 
echo CJSON::encode($shipment->shipping_charges);
?>
,
														x:5,
														y:5
													},
													{
														xtype:'textfield',
Exemplo n.º 23
0
<?php

/**
 * User: andrelinoge
 * Date: 12/9/12
 */
?>

<div class="row-form clearfix">
    <div class="span3"><?php 
echo $model->getAttributeLabel($attribute);
?>
</div>
    <div class="clear"></div>
    <div class="span11">
        <?php 
echo CHtml::activeTextArea($model, $attribute, $htmlOptions);
?>
        <span class="error" id="<?php 
echo CHtml::activeId($model, $attribute);
?>
_error">
            <?php 
echo $model->getError($attribute);
?>
        </span>
    </div>
</div>
Exemplo n.º 24
0
<div class="wide form">

    <?php 
$form = $this->beginWidget('CActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get', 'htmlOptions' => array('class' => 'form-horizontal')));
?>

<table>
    <tbody>
    <tr>
        <td> <?php 
echo $form->label($model, 'subdiv');
?>
            <?php 
echo $form->dropDownList($model, 'subdiv', CHtml::listData(Subdiv::model()->findAll(), 'id', 'name'), array('prompt' => 'Alegeți', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('tDb/Dynamicresp'), 'update' => '#' . CHtml::activeId($model, 'responsabil'))));
?>
</td>
        <td>
            <?php 
echo $form->label($model, 'responsabil');
?>
            <?php 
echo $form->DropDownList($model, 'responsabil', CHtml::listData(Responsabil::model()->findAllByAttributes(array('subdiv' => $model->subdiv)), 'id', 'fullname'), array('prompt' => 'Alegeți'));
?>
        </td>
    </tr>

    <tr>
        <td> <?php 
echo $form->label($model, 'date_reg');
?>
            <?php 
Exemplo n.º 25
0
?>
            <?php 
echo $form->dropDownList($model, 'type', $model->getArrayTypes(), array('prompt' => '----', "class" => "tooltipster", "title" => Yii::t('common', 'typeQuestion')));
?>
            <?php 
echo $form->error($model, 'type');
?>
        </div>
    </div>
    <div>
        <div class="col-lg-6">
            <?php 
echo $form->labelEx($model, 'idQuestionGroup');
?>
            <?php 
echo $form->dropDownList($model, 'idQuestionGroup', $model->getArrayGroups(), array('prompt' => '----', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('formulaire/dynamicquestions&id=' . $model->questionnaire->_id), 'update' => '#' . CHtml::activeId($model, 'idQuestionBefore')), "class" => "tooltipster", "title" => Yii::t('common', 'groupQuestion')));
?>
            <?php 
echo $form->error($model, 'idQuestionGroup');
?>
        </div>
        <div class="col-lg-6">
            <?php 
echo $form->labelEx($model, 'idQuestionBefore');
?>
            <?php 
echo $form->dropDownList($model, 'idQuestionBefore', array());
?>
            <?php 
echo $form->error($model, 'idQuestionBefore');
?>
Exemplo n.º 26
0
 /**
  *### .error()
  *
  * Displays the first validation error for a model attribute.
  *
  * @param CModel $model the data model
  * @param string $attribute the attribute name
  * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
  * @param boolean $enableAjaxValidation whether to enable AJAX validation for the specified attribute.
  * @param boolean $enableClientValidation whether to enable client-side validation for the specified attribute.
  * @return string the validation result (error display or success message).
  */
 public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true)
 {
     if (!$this->enableAjaxValidation) {
         $enableAjaxValidation = false;
     }
     if (!$this->enableClientValidation) {
         $enableClientValidation = false;
     }
     if (!isset($htmlOptions['class'])) {
         $htmlOptions['class'] = $this->errorMessageCssClass;
     }
     if (!$enableAjaxValidation && !$enableClientValidation) {
         return $this->renderError($model, $attribute, $htmlOptions);
     }
     $id = CHtml::activeId($model, $attribute);
     $inputID = isset($htmlOptions['inputID']) ? $htmlOptions['inputID'] : $id;
     unset($htmlOptions['inputID']);
     if (!isset($htmlOptions['id'])) {
         $htmlOptions['id'] = $inputID . '_em_';
     }
     $option = array('id' => $id, 'inputID' => $inputID, 'errorID' => $htmlOptions['id'], 'model' => get_class($model), 'name' => CHtml::resolveName($model, $attribute), 'enableAjaxValidation' => $enableAjaxValidation, 'inputContainer' => 'div.control-group');
     $optionNames = array('validationDelay', 'validateOnChange', 'validateOnType', 'hideErrorMessage', 'inputContainer', 'errorCssClass', 'successCssClass', 'validatingCssClass', 'beforeValidateAttribute', 'afterValidateAttribute');
     foreach ($optionNames as $name) {
         if (isset($htmlOptions[$name])) {
             $option[$name] = $htmlOptions[$name];
         }
         unset($htmlOptions[$name]);
     }
     if ($model instanceof CActiveRecord && !$model->isNewRecord) {
         $option['status'] = 1;
     }
     if ($enableClientValidation) {
         $validators = isset($htmlOptions['clientValidation']) ? array($htmlOptions['clientValidation']) : array();
         $attributeName = $attribute;
         if (($pos = strrpos($attribute, ']')) !== false && $pos !== strlen($attribute) - 1) {
             // e.g. [a]name
             $attributeName = substr($attribute, $pos + 1);
         }
         foreach ($model->getValidators($attributeName) as $validator) {
             /** @var $validator CValidator */
             if ($validator->enableClientValidation) {
                 if (($js = $validator->clientValidateAttribute($model, $attributeName)) != '') {
                     $validators[] = $js;
                 }
             }
         }
         if ($validators !== array()) {
             $option['clientValidation'] = "js:function(value, messages, attribute) {\n" . implode("\n", $validators) . "\n}";
         }
     }
     $html = $this->renderError($model, $attribute, $htmlOptions);
     if ($html === '') {
         if (isset($htmlOptions['style'])) {
             $htmlOptions['style'] = rtrim($htmlOptions['style'], ';') . '; display: none';
         } else {
             $htmlOptions['style'] = 'display: none';
         }
         $html = CHtml::tag('span', $htmlOptions, '');
     }
     $this->attributes[$inputID] = $option;
     return $html;
 }
Exemplo n.º 27
0
                 <div class="mws-button-row">
                    <?php 
echo Chtml::link('Back', Yii::app()->createUrl($this->module->id . '/' . $this->id . '/admin'), array('class' => 'mws-button gray left'));
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Create', array('class' => 'mws-button blue', 'type' => 'submit', 'onKeyPress' => 'return formSubmit(this,event)'));
echo CHtml::ResetButton($model->isNewRecord ? 'Reset' : 'Reset', array('class' => 'mws-button green'));
?>
                </div>   
                <?php 
$this->endWidget();
?>
            </div>
        </div>    	
    </div><!-- form -->
    
    
<?php 
Yii::app()->clientScript->registerScript('onheadfungsi', '
        function cekFingerPrint(){
            finger = $("#' . CHtml::activeId($model, 'no_fingerprint') . '").val();
            if (finger != ""){
                $.post("' . Yii::app()->createUrl('actionAjax/cekFinger') . '",{finger:finger, ' . ($model->isNewRecord ? '' : 'karyawan : ' . $model->karyawan_id) . '},function(data){
                    if (data != 1){
                        alert("No Finger Print telah diset untuk Karyawan lain");
                        $("#' . CHtml::activeId($model, 'no_fingerprint') . '").val("");
                        $("#' . CHtml::activeId($model, 'no_fingerprint') . '").focus();
                        $("#' . CHtml::activeId($model, 'no_fingerprint') . '").addClass("error");
                    }
                });
            }
        }
', CClientScript::POS_HEAD);
Exemplo n.º 28
0
</td>
		<td class="label"><?php 
echo $model->accountId == 0 ? $model->getAttributeLabel('accountName') : CHtml::link($model->getAttributeLabel('accountName'), array('accounts/view', 'id' => $model->accountId));
?>
</td>
		<td colspan="3" id="accountName" onclick="showField(this,true);">
			<div class="detail-field"><b><?php 
echo $model->accountName;
?>
</b></div>
			<div class="detail-form"><?php 
echo $form->hiddenField($model, 'accountName');
$this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'companyAutoComplete', 'value' => $model->accountName, 'source' => $this->createUrl('contacts/getTerms'), 'htmlOptions' => array('size' => 35, 'maxlength' => 100, 'tabindex' => 3), 'options' => array('minLength' => '2', 'select' => 'js:function( event, ui ) {
						$("#' . CHtml::activeId($model, 'accountId') . '").val(ui.item.id);
						$(this).val(ui.item.value);
						$("#' . CHtml::activeId($model, 'accountName') . '").val(ui.item.value);
						return false;
					}')));
echo $form->hiddenField($model, 'accountId');
?>
</div>
		</td>
	</tr>
	<?php 
$workflowList = Workflow::getList();
?>
	<tr id="workflow-row">
		<td class="label" width="20%"><?php 
echo $model->getAttributeLabel('status');
?>
</td>
Exemplo n.º 29
0
                <?php 
echo $form->dropDownList($personForm, 'minute', $personForm->minuteList, array('id' => 'person-minute-' . $tableCode, 'empty' => ' --- ', 'data-readonly' => true, 'class' => 'u-time-min'));
?>
                <?php 
echo $form->error($personForm, 'minute', array('inputID' => 'person-minute-' . $tableCode));
?>
            </span>

            <span class="form-control-checkbox">
                <?php 
echo $form->checkbox($personForm, 'notime', array('id' => 'person-notime-' . $tableCode, 'class' => 'u-data-time-toggle'));
?>
<i class="icn icn_checkbox"></i>
            </span>
            <label for="<?php 
echo CHtml::activeId($personForm, 'notime');
?>
">Время не известно</label>
        </div>
    </div>

     <div class="u-data__row u-data__row_place u-data-row-place">
        <div class="u-data__col u-data__col_left">Место рождения:</div>
        <div class="u-data__col u-data__col_right">
            <span class="form-control-select u-data__select-place">
            <?php 
$city = City::model()->findByPK($personForm->city_id);
$options = $city === null ? array() : array($city->id => $city->fullTitle);
echo $form->dropDownList($personForm, 'city_id', $options, array('id' => 'person-city_id-' . $tableCode, 'class' => 'u-place', 'data-get-places-list-url' => Yii::app()->createUrl('bazi/calculator/ajaxGetPlaces')));
?>
            </span>
Exemplo n.º 30
0
echo $form->labelEx($model, 'speciality');
?>
        <?php 
echo $form->dropDownList($model, 'speciality', Specialities::DropDown(), array('empty' => "", 'style' => "width: 100%;", "multiple" => "multiple"));
?>
    </div>


    <div class="form-actions">
        <?php 
$this->widget("bootstrap.widgets.TbButton", array('buttonType' => 'submit', 'type' => 'primary', "size" => "null", 'label' => $model->isNewRecord ? 'Створити' : 'Зберегти'));
?>
    </div> 


    <?php 
$this->endWidget();
?>
    <script>
        $("#spec-form-modal .switch").bootstrapSwitch();
        $('#<?php 
echo CHtml::activeId($model, "speciality");
?>
').select2({placeholder: "Обрати спеціальності", allowClear: true});
        //PSN.changeEntranceType($('#<?php 
echo CHtml::activeId($model, 'EntranceTypeID');
?>
').get(0));
    </script>
</div><!-- form -->