protected function initColumn() { $collection = new DaActiveRecordCollection($this->grid->dataProvider->getData()); $idObject = $this->getObject()->id_object; foreach ($collection as $key => $obj) { if (!Yii::app()->authManager->checkObjectInstance(DaDbAuthManager::OPERATION_DELETE, Yii::app()->user->id, $idObject, $key, false)) { $collection->remove($key); } else { $this->_availableIdInstance[] = $key; } } if ($collection->getCount() == 0) { $this->visible = false; return; } $info = $this->grid->dataProvider->model->isInstancesAvailableForDelete($collection); foreach ($info as $id => $availableInfo) { if (!$availableInfo['result']) { $key = array_search($id, $this->_availableIdInstance); unset($this->_availableIdInstance[$key]); $this->_unavailableInfo[$id] = implode(', ', $availableInfo['info']); } } $js = 'function da_deleteRecord(idObject, idInstance) { ' . CHtml::ajax(array('type' => 'POST', 'dataType' => 'json', 'url' => Yii::app()->createUrl('backend/ygin/deleteRecord'), 'data' => 'js:{idObject:idObject, idInstance:idInstance}', 'success' => 'function(data){ if (data.error !== undefined) {$.daSticker({text:data.error, type:"error", sticked:true}); $("#ygin_inst_" + data.idInstance + " .action-delete a").removeClass("process"); return;} $.daSticker({text:data.message, type:"success"}); $("#ygin_inst_" + data.idInstance).remove(); if ($(".b-instance-list tbody tr").length == 0) {$(".b-instance-list, .b-instance-list-count").remove();} }')) . ' }'; Yii::app()->clientScript->registerScript('admin.delete-record-ajax', $js, CClientScript::POS_HEAD); }
protected function updatePriorityAjax($model_id, $dir, $update) { $url = array('/' . $this->getOwner()->getRoute()); $data = $_GET; $data['direction'] = $dir; $data['model_id'] = $model_id; return CHtml::ajax(array('update' => $update, 'url' => $url, 'type' => 'get', 'data' => $data)); }
/** * * @param CActiveRecord $model * @param int $id * @param array $config */ public function registerAssignScript($model, $id, array $config = array()) { Yii::app()->controller->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'assignDriver', "options" => array('title' => 'Assign Driver', 'autoOpen' => false, 'modal' => true, 'buttons' => array('Close' => 'js:function(){$(this).dialog("close")}', 'Assign' => 'js:function(){' . CHtml::ajax(array('url' => $config['ajaxUrl'], 'type' => 'post', 'dataType' => 'json', 'data' => 'js:$("#assignDriver form").serialize()', 'success' => 'function(r){if(r.success){ $("#assignDriver").dialog("close"); $.fn.yiiGridView.update("tracking-grid"); }; if(!r.success){alert("Gagal assign driver")}}')) . ';}'))), true); $driverForm = new CForm(array('elements' => array('driver' => array('type' => 'dropdownlist', 'items' => OrderTracking::getDriverList()), 'id' => array('type' => 'hidden'))), $model); echo $driverForm->render(); Yii::app()->controller->endWidget(); Yii::app()->clientScript->registerScript($id, "jQuery('body').undelegate('.assignDriver_button','click').delegate('.assignDriver_button','click',function(){\ndriverDialog=jQuery('#assignDriver');\ndriverDialog.dialog('open');\njQuery('#assignDriver input#OrderTracking_id').val(\$(this).attr('rel').replace('grid.',''));\n\treturn false;\n});\t"); }
public function init() { $data = $this->grid->dataProvider->getData(); if (count($data) == 0) { return; } $userId = Yii::app()->user->id; $idObject = $this->object->id_object; $idObjectParameter = $this->objectParameter->getIdParameter(); $ok = false; foreach ($data as $instance) { $idInstance = $instance->getIdInstance(); if (Yii::app()->authManager->checkObjectParameter($userId, $idObject, $idInstance, $idObjectParameter)) { $this->_permission[$idInstance] = true; $ok = true; } else { $this->_permission[$idInstance] = false; } } if (!$ok) { return; } Yii::app()->controller->registerJsFile('ygin_visual_element.js', 'backend.assets.js'); $js = 'function da_booleanColumn(idInstance, idObject, idObjectParameter) { ' . CHtml::ajax(array('type' => 'POST', 'dataType' => 'json', 'url' => Yii::app()->createUrl('backend/ygin/booleanColumn'), 'data' => 'js:{idObject:idObject, idInstance:idInstance, idObjectParameter:idObjectParameter}', 'success' => 'function(data){ if (data.error !== undefined) { $.daSticker({text:data.error, type:"error", sticked:true}); } else { $.daSticker({text:data.message, type:"success"}); } newClass = "glyphicon glyphicon-remove icon-red editable"; if (data.value == 1) newClass = "glyphicon glyphicon-ok icon-green editable"; $("#bool_" + data.idInstance + "_" + data.idObjectParameter).removeClass().addClass(newClass); }')) . ' }'; Yii::app()->clientScript->registerScript('admin.booleanColumn-ajax', $js, CClientScript::POS_HEAD); }
public function testAjaxCallbacks() { $out = CHtml::ajax(array('success' => 'js:function() { /* callback */ }')); $this->assertTrue(mb_strpos($out, "'success':function() { /* callback */ }", null, Yii::app()->charset) !== false, "Unexpected JavaScript: " . $out); $out = CHtml::ajax(array('success' => 'function() { /* callback */ }')); $this->assertTrue(mb_strpos($out, "'success':function() { /* callback */ }", null, Yii::app()->charset) !== false, "Unexpected JavaScript: " . $out); $out = CHtml::ajax(array('success' => new CJavaScriptExpression('function() { /* callback */ }'))); $this->assertTrue(mb_strpos($out, "'success':function() { /* callback */ }", null, Yii::app()->charset) !== false, "Unexpected JavaScript: " . $out); }
</tr> <tr><th style="text-align:center;">Grupo</th> <th style="text-align:center;">SubGrupo</th> <th style="text-align:center;">Seccion</th> </tr> </thead> <tbody id="data2"> <?php $this->renderPartial('_ajaxContent2'); ?> </tbody> </table> <script> function prueba() { <?php echo CHtml::ajax(array('type' => 'POST', 'url' => array("traspaso/actualizarAjax"), 'update' => '#data2', 'data' => array())); ?> } prueba(); </script> </div> </fieldset> <div class="row buttons"> <?php echo CHtml::link('Cancelar', array('delete', 'id' => $model->id), array('class' => 'button red')) . ' '; echo CHtml::submitButton('Siguiente', array('class' => 'button blue')); ?> </div>
</script> <script type="text/javascript"> function editdata1() { <?php echo CHtml::ajax(array('url' => array('invoicear/updateinvoicedet'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detail1datagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n {\ndocument.getElementById('messages').innerHTML = '';\n if (data.status == 'success')\n {\n \$('#createdialog1 div.divcreate1').html(data.div);\n\t\t\t\t\t\$('#Invoicedet_invoicedetid').val(data.invoicedetid);\n\t\t\t\t\t\$('#Invoicedet_itemname').val(data.itemname);\n\t\t\t\t\t\$('#Invoicedet_qty').val(data.qty);\n\t\t\t\t\t\$('#Invoicedet_unitofmeasureid').val(data.unitofmeasureid);\n\t\t\t\t\t\$('#uomcode').val(data.uomcode);\n\t\t\t\t\t\$('#Invoicedet_price').val(data.price);\n\t\t\t\t\t\$('#Invoicedet_currencyid').val(data.currencyid);\n\t\t\t\t\t\$('#invdetcurrencyname').val(data.currencyname);\n\t\t\t\t\t\$('#Invoicedet_rate').val(data.rate);\n\t\t\t\t\t\$('#Invoicedet_description').val(data.description);\n // Here is the trick: on submit-> once again this function!\n \$('#createdialog1').dialog('open');\n }\n else {\n document.getElementById('messages').innerHTML = data.div;\n }\n } ")); ?> ; return false; } </script> <script type="text/javascript"> function deletedata1() { <?php echo CHtml::ajax(array('url' => array('soheader/deleteinvoicedet'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detail1datagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n {\n\n } ")); ?> ; $.fn.yiiGridView.update('detail1datagrid'); return false; } </script> <script type="text/javascript"> function refreshdata1() { $.fn.yiiGridView.update('detail1datagrid'); return false; } </script> <?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'createdialog1', 'options' => array('title' => 'Form Dialog', 'autoOpen' => false, 'modal' => true, 'width' => 'auto', 'height' => 'auto')));
<?php if ($dataProvider != null) { if (isset($imageList) && $imageList == true) { echo "<div id='imageId' style='display:none'></div>"; $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'imageDeleteConfirmation', 'options' => array('title' => Yii::t('general', 'Delete Image'), 'autoOpen' => false, 'modal' => true, 'resizable' => false, 'buttons' => array("OK" => "js:function(){\n\t\t\t\t\t\t\t\t\t" . CHtml::ajax(array('url' => Yii::app()->createUrl('image/delete'), 'data' => array('id' => "js:\$('#imageId').html()"), 'success' => 'function(result) { try { $("#imageDeleteConfirmation").dialog("close"); var obj = jQuery.parseJSON(result); if (obj.result && obj.result == "1") { $.fn.yiiGridView.update("imageListView"); } else { $("#messageDialogText").html("Sorry,an error occured in operation"); $("#messageDialog").dialog("open"); } } catch(ex) { $("#messageDialogText").html("Sorry,an error occured in operation"); $("#messageDialog").dialog("open"); } }')) . "}", "Cancel" => "js:function() {\n\t\t\t\t\t\t\$( this ).dialog( \"close\" );\n\t\t\t\t\t}")))); echo "Do you want to delete this image?"; $this->endWidget('zii.widgets.jui.CJuiDialog'); } $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $dataProvider, 'id' => 'imageListView', 'summaryText' => '', 'pager' => array('header' => '', 'firstPageLabel' => '', 'lastPageLabel' => ''), 'columns' => array(array('type' => 'raw', 'value' => 'CHtml::link("<img src=\\"".Yii::app()->createUrl("image/get", array( "id"=>$data["id"], "thumb"=>"ok"
/** * Render a message */ protected function renderMessage($messageType, $message, $htmlOptions) { //render as javascript alert if ($messageType == 'js_alert') { $script = "alert('{$message}');"; Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $htmlOptions['id'], $script); } else { //render as ajax request if ($messageType == 'jq_ajax') { $this->_registerJQuery = true; echo CHtml::tag($this->tag, $htmlOptions, ''); $script = CHtml::ajax(array('url' => $message, 'type' => 'get', 'update' => '#' . $htmlOptions['id'])); Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $htmlOptions['id'], $script); } else { echo CHtml::tag($this->tag, $htmlOptions, $message); } } }
</script> <script type="text/javascript"> function editdata1() { <?php echo CHtml::ajax(array('url' => array('product/updatebasic'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detailbasicdatagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n {\ndocument.getElementById('messages').innerHTML = '';\n if (data.status == 'success')\n {\n \$('#createdialog1 div.divcreate1').html(data.div);\n\t\t\t\t\t\$('#Productbasic_productbasicid').val(data.productbasicid);\n\t\t\t\t\t\$('#Productbasic_baseuom').val(data.baseuom);\n\t\t\t\t\t\$('#baseuomcode').val(data.baseuomcode);\n\t\t\t\t\t\$('#Productbasic_materialgroupid').val(data.materialgroupid);\n\t\t\t\t\t\$('#materialgroupcode').val(data.materialgroupcode);\n\t\t\t\t\t\$('#Productbasic_oldmatno').val(data.oldmatno);\n\t\t\t\t\t\$('#Productbasic_grossweight').val(data.grossweight);\n\t\t\t\t\t\$('#Productbasic_weightunit').val(data.weightunit);\n\t\t\t\t\t\$('#weightunitcode').val(data.weightunitcode);\n\t\t\t\t\t\$('#Productbasic_netweight').val(data.netweight);\n\t\t\t\t\t\$('#Productbasic_volume').val(data.volume);\n\t\t\t\t\t\$('#Productbasic_volumeunit').val(data.volumeunit);\n\t\t\t\t\t\$('#volumeunitcode').val(data.volumeunitcode);\n\t\t\t\t\t\$('#Productbasic_sizedimension').val(data.sizedimension);\n\t\t\t\t\t\$('#Productbasic_materialpackage').val(data.materialpackage);\n\t\t\t\t\t\$('#materialpackagename').val(data.materialpackagename);\n // Here is the trick: on submit-> once again this function!\n \$('#createdialog1').dialog('open');\n }\n else {\n document.getElementById('messages').innerHTML = data.div;\n }\n } ")); ?> ; return false; } </script> <script type="text/javascript"> function deletedata1() { <?php echo CHtml::ajax(array('url' => array('product/deletebasic'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detailbasicdatagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n {\n\n } ")); ?> ; $.fn.yiiGridView.update('detail1datagrid'); return false; } </script> <script type="text/javascript"> function refreshdata1() { $.fn.yiiGridView.update('detailbasicdatagrid'); return false; } </script> <?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'createdialog1', 'options' => array('title' => 'Form Dialog', 'autoOpen' => false, 'modal' => true, 'width' => 'auto', 'height' => 'auto')));
} function reSetBlocksByParent(data){ $.each(data, function(key_parent, val_parent){ if(key_parent=='blocks'){ $.each(val_parent, function(k,v) { setBlocksForRegion(v.region,v.title,v.id,v.status); }); } }); } function getRegionsByLayouts(){ <?php echo CHtml::ajax(array('url' => array('changeLayout'), 'data' => array('layout' => 'js:$(\'#layout_select\').val()', 'YII_CSRF_TOKEN' => Yii::app()->getRequest()->getCsrfToken()), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n { \n block_count=0;\n createRegionsFromJson(data);\n initBlocks();\n } ")); ?> } function setBlocksForRegion(region,title,id,status){ var span_html='<input type="checkbox" class="checkbox_region" id="checkbox_'+block_count+'_'+region+'_'+id+'"/><span class="span_block">'+title+'</span> - <span><select name="Page[regions]['+region+'][status][]" id="select_region_'+block_count+'_'+region+'_'+id+'"><option value="<?php echo ConstantDefine::PAGE_BLOCK_ACTIVE; ?> "><?php echo PageBlock::convertPageBlockStatus(ConstantDefine::PAGE_BLOCK_ACTIVE); ?> </option><option value="<?php echo ConstantDefine::PAGE_BLOCK_DISABLE; ?> "><?php echo PageBlock::convertPageBlockStatus(ConstantDefine::PAGE_BLOCK_DISABLE);
/** * Registers the needed client scripts. * @since 1.0.2 */ public function registerClientScript() { $cs = Yii::app()->clientScript; $id = $this->imageOptions['id']; $url = $this->getController()->createUrl($this->captchaAction, array(CCaptchaAction::REFRESH_GET_VAR => true)); if ($this->showRefreshButton) { $cs->registerScript('Yii.CCaptcha#' . $id, 'dummy'); $label = $this->buttonLabel === null ? Yii::t('yii', 'Get a new code') : $this->buttonLabel; $button = $this->buttonType === 'button' ? 'ajaxButton' : 'ajaxLink'; $html = CHtml::$button($label, $url, array('success' => 'js:function(html){jQuery("#' . $id . '").attr("src",html)}'), $this->buttonOptions); $js = "jQuery('#{$id}').after(\"" . CJavaScript::quote($html) . '");'; $cs->registerScript('Yii.CCaptcha#' . $id, $js); } if ($this->clickableImage) { $js = "jQuery('#{$id}').click(function(){" . CHtml::ajax(array('url' => $url, 'success' => "js:function(html){jQuery('#{$id}').attr('src',html)}")) . '});'; $cs->registerScript('Yii.CCaptcha#2' . $id, $js); } }
</div> </div> </div> <div class="row buttons"> <?php echo $form->hiddenField($new_event, 'user_id', array('value' => Yii::app()->user->id)); ?> <?php echo CHtml::submitButton('Update'); ?> </div> <?php $this->endWidget(); ?> </div><!-- form --> <?php $ajax = CHtml::ajax(array('url' => array('selectRemarks'), 'dataType' => 'html', 'type' => 'post', 'data' => 'js: {status_id:$(this).val()} ', 'success' => 'function(data){ $("#rm").children().remove(); $("#rm").append(data); return true; }')); $cs = Yii::app()->clientScript; $script = <<<SCRIPT \$('#ShipmentEvent_status').live('change',function(){ {$ajax} }); SCRIPT; $cs->registerScript('change_status', $script);
/* * if status is zero, it means friend ship request is made and not yet confirmed. * requester who made first friend request. if one is requester he cannot approve friendship */ ?> <div style='float: left;'> <?php echo CHtml::link('<img src="images/approve.png" />', '#', array('onclick' => CHtml::ajax(array('url' => $this->createUrl('users/approveFriendShip', array('friendShipId' => $data['friendShipId'])), 'success' => 'function(result) { alert(result); }')))); ?> </div> <?php } else { if (isset($data['status']) && $data['status'] == -1) { /* * if status is not exist or equal to -1 it means there is no relation between these users. */ ?> <div style='float: left;'> <?php echo CHtml::link('<img src="images/user_add_friend.png" />', '#', array('onclick' => CHtml::ajax(array('url' => $this->createUrl('users/addAsFriend', array('friendId' => $data['id'])), 'success' => 'function(result) { alert(result); }')))); ?> </div> <?php } } ?> </div> </br>
$this->beginWidget('bootstrap.widgets.TbModal', array('id' => 'ModalDialog')); ?> <div class="modal-header"> <a class="close" data-dismiss="modal">x</a> <h3><?php echo $this->modalTitle; ?> </h3> </div> <div class="modal-body"> </div> <?php $this->endWidget(); ?> <script type="text/javascript"> // here is the magic function dialogJavaScript() { <?php echo CHtml::ajax(array('url' => $this->ajaxCreateURL, 'data' => "js:\$(this).serialize()", 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\r\n {\r\n if (data.status == 0)\r\n {\r\n \$('#ModalDialog div.modal-body').html(data.div);\r\n // Here is the trick: on submit-> once again this function!\r\n \$('#ModalDialog div.modal-body form').submit(dialogJavaScript);\r\n }\r\n else\r\n {\r\n setTimeout(\"\$('#ModalDialog').modal('hide') \", 500);\r\n // Refresh the grid with the update\r\n //\$.fn.yiiGridView.update('grid-view');\r\n \$('#grid-view').yiiGridView('update');\r\n }\r\n \r\n }")); ?> ; return false; } </script>
/** * @dataProvider providerAjax * * @param type $options * @param type $assertion */ public function testAjax($options, $assertion) { $this->assertEquals($assertion, CHtml::ajax($options)); }
<?php echo CHtml::Button(t('cms', 'Send'), array('class' => 'button active', 'onClick' => 'return doFormSave();', 'style' => 'display:block;width:100px')); ?> <div class="clear"></div> <script type="text/javascript"> function doFormSave(){ $("#form_send_to").val(''); $("#which_button").val(1); $('#object-form').submit(); } function doFormSend(){ var formPerson=$("#form_send_to").val(); $("#which_button").val(2); //Start to check the current user is allowed to transfered to if(formPerson==''){ alert('<?php echo t("cms", "Please choose a name"); ?> '); return false; } else { <?php echo CHtml::ajax(array('url' => bu() . '/beobject/checktransferrights', 'data' => array('q' => 'js:$(\'#form_send_to\').val()', 'type' => $type, 'YII_CSRF_TOKEN' => Yii::app()->getRequest()->getCsrfToken()), 'type' => 'post', 'dataType' => 'html', 'success' => "function(data)\n { \n // Update the status\n if (data=='0')\n {\n alert('" . t('cms', 'You are not allowed to send content to this user') . "');\n return;\n } else {\n \$('#object-form').submit();\n return;\n }\n\n } ")); ?> } return false; } </script> </div>
</style> <script type="text/javascript"> function updateCourseUnit() { <?php echo CHtml::ajax(array('url' => array('courseUnitTable/newUpdate?id=' . $_REQUEST['id']), 'data' => "js:\$(this).serialize()", 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n {\n if (data.status == 'failure')\n {\n \$('#updateCourseUnit div.divUpdateForm').html(data.div);\n \$('#updateCourseUnit div.divUpdateForm form').submit(updateCourseUnit);\n }\n else\n {\n\t\t \$('#updateCourseUnit').dialog('close');\n\t\t window.location='admin?id='+{$course};\n }\n \n } ")); ?> ; return false; } function addLessonUnit() { <?php echo CHtml::ajax(array('url' => array('unitDetailTable/newcreate?id=' . $_REQUEST['id'] . '&cid=' . $course), 'data' => "js:\$(this).serialize()", 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n {\n if (data.status == 'failure')\n {\n \$('#addLesson div.divLessonForm').html(data.div);\n \$('#addLesson div.divLessonForm form').submit(addLessonUnit);\n }\n else\n {\n\t\t \$('#addLesson').dialog('close');\n\t\t window.location='admin?id='+{$course};\n }\n \n } ")); ?> ; return false; } </script> <?php $this->breadcrumbs = array('Course Master' => array('courseMaster/admin'), 'Manage'); ?> <h1>View Course Unit Details </h1> <div class="ope">
?> <?php echo CHtml::activeDropDownList($model, 'idn1', CHtml::listData(Ubicacion::model()->findAll('TipoUbicacion_idTipoUbicacion = 1'), 'idUbicacion', 'Nombre'), array('onchange' => CHtml::ajax(array('type' => 'POST', 'url' => CController::createUrl('ubicacion/selectmunicipio'), 'update' => '#Accidente_idn2')), 'prompt' => 'Seleccione uno')); ?> <?php echo $form->error($model, 'Ubicacion_idUbicacion'); ?> </div> <div class="row"> <?php echo '<b>Municipio</b><br/>'; ?> <?php echo CHtml::activeDropDownList($model, 'idn2', array(), array('onchange' => CHtml::ajax(array('type' => 'POST', 'url' => CController::createUrl('ubicacion/selectparroquia'), 'update' => '#Accidente_Ubicacion_idUbicacion')), 'prompt' => 'Seleccione uno')); ?> <?php echo $form->error($model, 'Ubicacion_idUbicacion'); ?> </div> <div class="row"> <?php echo '<b>Parroquia</b><br/>'; ?> <?php echo $form->dropDownList($model, 'Ubicacion_idUbicacion', array(), array('prompt' => 'Seleccione una')); ?> <?php
echo CHtml::ajaxButton('Agregar', CController::createUrl('fbm3/AgregarAjax'), $options, array('class' => 'button blue')); ?> </div> <div style="margin:10px 0"> <div class="table-grey" style="min-height:150px"> <h2>Bienes Muebles Adscritos</h2> <div id="data2"> <?php $this->renderPartial('_content2'); ?> </div> </div> <script> function prueba() { <?php echo CHtml::ajax(array('type' => 'POST', 'url' => array("fbm3/ActualizarAjax"), 'update' => '#data2', 'data' => array('fbmid' => $_GET['id']))); ?> } prueba(); </script> </div> <div class="right"> <?php //echo CHtml::button('Cancelar', array('submit' => array('delete', 'id'=>$_GET['id']))).' '; $imghtml = CHtml::image('images/no_med.png', 'Cancelar', array('title' => 'Cancelar')); echo CHtml::link($imghtml, array('delete', 'id' => $_GET['id'])) . ' '; //echo CHtml::button('Siguiente', array('submit' => array('formBm3/generar','id'=>$_GET['id'] ))); $imghtml2 = CHtml::image('images/Forward.png', 'Siguiente', array('title' => 'Siguiente')); echo CHtml::link($imghtml2, array('fbm3/generar', 'id' => $_GET['id'])); ?> </div>
public static function generateManualAjaxLink($label, $ajaxOptions, $htmlOptions) { if ($htmlOptions == null) { $htmlOptions == array(); } $htmlOptions["onClick"] = " {" . CHtml::ajax($ajaxOptions, $htmlOptions) . "; event.stopPropagation(); return false; }"; $htmlOptions["id"] = "ajax-id-" . uniqid(); return CHtml::link($label, "#", $htmlOptions); }
</script> <script type="text/javascript"> function editdata() { <?php echo CHtml::ajax(array('url' => array('sloc/update'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("datagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\r\n {\r\ndocument.getElementById('messages').innerHTML = '';\r\n if (data.status == 'success')\r\n {\r\n \$('#createdialog div.divcreate').html(data.div);\r\n\t\t\t\t\t\$('#Sloc_slocid').val(data.slocid);\r\n\t\t\t\t\t\$('#Sloc_plantid').val(data.plantid);\r\n\t\t\t\t\t\$('#Sloc_sloccode').val(data.sloccode);\r\n\t\t\t\t\t\$('#Sloc_description').val(data.description);\r\n\t\t\t\t\t\$('#plant_code').val(data.plantcode);\r\n\t\t\t\t\tif (data.recordstatus == '1')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t document.forms[1].elements[9].checked=true;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t document.forms[1].elements[9].checked=false;\r\n\t\t\t\t\t}\r\n // Here is the trick: on submit-> once again this function!\r\n \$('#createdialog').dialog('open');\r\n }\r\n else\r\n {\r\n document.getElementById('messages').innerHTML = data.div;\r\n }\r\n } ")); ?> ; return false; } </script> <script type="text/javascript"> function deletedata() { <?php echo CHtml::ajax(array('url' => array('sloc/delete'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("datagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\r\n {\r\n\r\n } ")); ?> ; $.fn.yiiGridView.update('datagrid'); return false; } </script> <script type="text/javascript"> function refreshdata() { $.fn.yiiGridView.update('datagrid'); return false; } </script> <script type="text/javascript"> function helpdata(value) {
</script> <script type="text/javascript"> function editdata1() { <?php echo CHtml::ajax(array('url' => array('employee/updateaddress'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detail1datagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n {\ndocument.getElementById('messages').innerHTML = '';\n if (data.status == 'success')\n {\n \$('#createdialog1 div.divcreate1').html(data.div);\n\t\t\t\t\t\$('#Employeeaddress_addressid').val(data.addressid);\n\t\t\t\t\t\$('#Employeeaddress_addresstypeid').val(data.addresstypeid);\n\t\t\t\t\t\$('#addresstypename').val(data.addresstypename);\n\t\t\t\t\t\$('#Employeeaddress_addressname').val(data.addressname);\n\t\t\t\t\t\$('#Employeeaddress_rt').val(data.rt);\n\t\t\t\t\t\$('#Employeeaddress_rw').val(data.rw);\n\t\t\t\t\t\$('#Employeeaddress_cityid').val(data.cityid);\n\t\t\t\t\t\$('#cityname').val(data.cityname);\n\t\t\t\t\t\$('#Employeeaddress_kelurahanid').val(data.kelurahanid);\n\t\t\t\t\t\$('#kelurahanname').val(data.kelurahanname);\n\t\t\t\t\t\$('#Employeeaddress_subdistrictid').val(data.subdistrictid);\n\t\t\t\t\t\$('#subdistrict_name').val(data.subdistrictname);\n\t\t\t\t\tif(data.recordstatus=='1')\n{document.forms[1].elements[18].checked=true;}\nelse\n{document.forms[1].elements[18].checked=false;}\n // Here is the trick: on submit-> once again this function!\n \$('#createdialog1').dialog('open');\n }\n else {\n document.getElementById('messages').innerHTML = data.div;\n }\n } ")); ?> ; return false; } </script> <script type="text/javascript"> function deletedata1() { <?php echo CHtml::ajax(array('url' => array('employee/deletedetail'), 'data' => array('id' => 'js:$.fn.yiiGridView.getSelection("detaildatagrid")'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n {\n\n } ")); ?> ; $.fn.yiiGridView.update('detail1datagrid'); return false; } </script> <script type="text/javascript"> function refreshdata1() { $.fn.yiiGridView.update('detail1datagrid'); return false; } </script> <?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'createdialog1', 'options' => array('title' => 'Form Dialog', 'autoOpen' => false, 'modal' => true, 'width' => 'auto', 'height' => 'auto')));
}); $("#creditcard").click( function(){ <?php echo CHtml::ajax(array( 'url'=>array('ajaxCreditCard'), 'data'=> array( 'id_sched'=>$id_sched, 'sumtopay'=>'js:getasum()', 'payers'=>'js:countcard()', // 'payers'=>'js:cardpays', 'date'=>$sched['date'], 'time'=>$sched['starttime']), 'type'=>'post', 'dataType'=>'json', 'success'=>"function(data) { if (data.status == 'failure'){ // psqdata = $.parseJSON(data.div); $('#card-title-data').html(' tourists: '+data.payers+' total: '+data.sum); // $('#card-sys-data').html(data.payers); $('#card-modal-data').html(data.div.html); } else { psqdata = $.parseJSON(data.div); $('#card-modal-data').html(psqdata.html); } } ", ))?>; return true; });
?> <div class="pluginActionPending"><?php echo Theme::img('gridview/loading.gif'); ?> </div> <?php echo Yii::t('mc', 'Please wait for the action to complete.'); ?> </div> <?php if ($i != $show) { echo CHtml::script(' function refresh() { ' . CHtml::ajax(array('type' => 'POST', 'dataType' => 'json', 'success' => 'js:set_status', 'data' => array('ajax' => 'get_status', Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken))) . ' } function set_status(data) { var expect = "' . $show . '"; if (expect == data) { $("#pending").hide(); $("#regular").show(); return; } scheduleRefresh(); } function scheduleRefresh(delay) { setTimeout(function() { refresh(); }, ' . $this->ajaxUpdateInterval . ');
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => $i, 'options' => array('autoOpen' => false, 'modal' => false, 'width' => 'auto', 'height' => 'auto', 'resizable' => false, 'close' => 'js:function(){ var ni = document.getElementById("module' . $i . '"); ni.innerHTML = ""; }'))); ?> <div id='module<?php echo $i; ?> '></div> <?php $this->endWidget(); } ?> <script type="text/javascript"> function loadmodule(value) { <?php echo CHtml::ajax(array('url' => array('site/loadmodule'), 'data' => array('id' => 'js:value'), 'type' => 'post', 'dataType' => 'json', 'success' => "function(data)\n {\n if (data.status == 'success')\n {\n\t\t\t\t\tvar x = 0;\n\t\t\t\t\tvar ni = null;\n\t\t\t\t\tfor (var i=1; i<=" . Yii::app()->params['maxform'] . "; i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tni = document.getElementById('module'+i);\n\t\t\t\t\t\tif (ni !== null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (ni.innerHTML == '')\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tni.innerHTML = data.div\n\t\t\t\t\t\t\t\t\$('#'+i).dialog('option','title',data.modulename);\n\t\t\t\t\t\t\t\t\$('#'+i).dialog('open');\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n }\n } ")); ?> ; return false; } </script> <script> $(document).ready(function(){ $('#desktop').css("background-image", "url(<?php echo Yii::app()->request->baseurl . '/images/' . $useraccess->wallpaper; ?> )"); }); </script> </body> </html>
<?php echo CHtml::button('Ok', array('onclick' => CHtml::ajax(array('url' => Yii::app()->getRequest()->getUrl(), 'update' => '.fancybox-inner', 'type' => 'post', 'data' => array('ok' => true))))); echo CHtml::button('Отмена', array('onclick' => '$.fancybox.close()'));
?> </div> <div class="row buttons"> <?php echo CHtml::ajaxSubmitButton('Login', $this->createUrl('site/login'), array('success' => 'function(result){ try { var obj = jQuery.parseJSON(result); if (obj.result && obj.result == "1") { $("#username").html(obj.realname); $("#userId").html(obj.id); //TRACKER.getFriendList(1); $("#lists").show(); $("#tab_view").tabs("select",0); ' . CHtml::ajax(array('url' => $this->createUrl('users/getFriendList'), 'update' => '#users_tab')) . ' ' . CHtml::ajax(array('url' => $this->createUrl('image/getList'), 'update' => '#photos_tab')) . ' $("#loginBlock").hide(); $("#userBlock").show(); $("#userLoginWindow").dialog("close"); TRACKER.getFriendList(1); TRACKER.getImageList(); } } catch (error){ $("#userLoginWindow").html(result); } }'), null); ?> </div>
<?php $language = TranslateModule::translator(); $languageKey = $language->languageKey; $google = !empty(TranslateModule::translator()->googleApiKey) ? true : false; Yii::app()->controller->pageTitle = TranslateModule::t('Translate to {lang}', array('{lang}' => $language->acceptedLanguages[$language->getLanguage()])); ?> </h2 <?php if ($google) { echo CHtml::link(TranslateModule::t('Translate all with google translate'), "#", array('id' => $languageKey . "-google-translateall")); echo CHtml::script("\$('#{$languageKey}-google-translateall').click(function(){\r\n var messages=[];\$('.{$languageKey}-google-message').each(function(count){\r\n messages[count]=\$(this).html();\r\n });" . CHtml::ajax(array('url' => $this->createUrl('translate/googletranslate'), 'type' => 'post', 'dataType' => "json", 'data' => array('language' => Yii::app()->getLanguage(), 'sourceLanguage' => Yii::app()->sourceLanguage, 'message' => 'js:messages'), 'success' => "js:function(response){\r\n \$('.{$languageKey}-google-translation').each(function(count){\r\n \$(this).val(response[count]);\r\n });\r\n \$('.{$languageKey}-google-button,#{$languageKey}-google-translateall').hide();\r\n }", 'error' => 'js:function(xhr){alert(xhr.statusText);}')) . "\r\n return false;\r\n });\r\n "); if (Yii::app()->getRequest()->isAjaxRequest) { echo CHtml::script("\r\n \$('#" . TranslateModule::translator()->languageKey . '-pager' . " a').click(function(){\r\n \$dialog=\$('#" . TranslateModule::translator()->languageKey . '-dialog' . "').load(\$(this).attr('href'));\r\n return false;\r\n });\r\n "); } } ?> <div class="form"> <?php echo CHtml::beginForm(); ?> <table> <thead> <th><?php echo MessageSource::model()->getAttributeLabel('category'); ?> </th> <th><?php echo MessageSource::model()->getAttributeLabel('message'); ?> </th>
echo $form->error($model, 'accountnr'); ?> </div> </div> <div id="tabs-4"> <?php /** * creating ajax function untuk mencari daftar city berdasarkan provinceId * return array dari city * */ $sugggestCity = CHtml::ajax(array('url' => array('shipment/suggestCity'), 'dataType' => 'json', 'data' => array('term' => 'js:request.term', 'pid' => 'js:$("input#province_id").val()'), 'success' => 'js:function(data){ realData=$.makeArray(data); response($.map(realData, function (item){return{ did:item.did, zid:item.zid, value:item.value, label:item.label } })) }')); ?> <div class="row"> <?php echo $form->labelEx($contact, 'jabatan'); ?> <?php echo $form->textField($contact, 'jabatan'); ?> <?php echo $form->error($contact, 'jabatan'); ?>