Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Oct 29th, 2009  |  syntax: PHP  |  size: 6.03 KB  |  hits: 113  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. $optionsCity = array(
  3.     'name' => 'Daytrip[City]',
  4.     'url' => array('daytrip/AutoCompleteCity'),
  5.     'max' => 10,
  6.     'minChars' => 2,
  7.     'delay' => 500,
  8.     'matchCase' => false,
  9.     'methodChain' => '.result(function(event, item) { $("#Daytrip_CityId").val(item[1]); })',
  10.     'value' => $daytrip->rCity->City,
  11. );
  12. $optionsTag = array(
  13.     'name' => 'Daytrip[Tags]',
  14.     'url' => array('daytrip/AutoCompleteTag'),
  15.     'max' => 10,
  16.     'minChars' => 2,
  17.     'delay' => 500,
  18.     'matchCase' => false,
  19.     'multiple' => true,
  20.     'model' => $daytrip,
  21.     'value' => (count($daytrip->getTagArray()) > 0) ? implode(', ', $daytrip->getTagArray()) . ', ' : '',
  22. );
  23. ?>
  24. <?php echo CHtml::errorSummary($daytrip); ?>
  25. <?php echo CHtml::beginForm('', 'post', array('enctype' => 'multipart/form-data')); ?>
  26. <fieldset>
  27.     <legend><?php echo Yii::t('labels', $update ? 'Edit Daytrip' : 'Create Daytrip'); ?></legend>
  28.     <ol>
  29.         <li>
  30.             <?php echo CHtml::activeLabelEx($daytrip, 'Daytrip'); ?>
  31.             <?php echo CHtml::activeTextField($daytrip, 'Daytrip'); ?>
  32.         </li>
  33.         <li>
  34.             <?php echo CHtml::activeLabelEx($daytrip, 'ContactPerson'); ?>
  35.             <?php echo CHtml::activeTextField($daytrip, 'ContactPerson'); ?>
  36.         </li>
  37.         <li>
  38.             <?php echo CHtml::activeLabelEx($daytrip, 'Street'); ?>
  39.             <?php echo CHtml::activeTextField($daytrip, 'Street'); ?>
  40.         </li>
  41.         <li>
  42.             <?php echo CHtml::activeLabelEx($daytrip, 'Number'); ?>
  43.             <?php echo CHtml::activeTextField($daytrip, 'Number'); ?>
  44.             <?php echo CHtml::link('Zoek Postcode', '', array('id' => 'getZipCode')); ?>
  45.         </li>
  46.         <li>
  47.             <?php echo CHtml::activeLabelEx($daytrip, 'ZipCode'); ?>
  48.             <?php echo CHtml::activeTextField($daytrip, 'ZipCode'); ?>
  49.             <?php echo CHtml::link('Zoek straat', '', array('id' => 'getAddress')); ?>
  50.         </li>
  51.         <li>
  52.             <?php echo CHtml::activeLabelEx($daytrip, 'City'); ?>
  53.             <?php $this->widget('CAutoComplete', $optionsCity); ?>
  54.             <?php echo CHtml::activeHiddenField($daytrip, 'CityId'); ?>
  55.             <!-- temp --><?php echo $daytrip->old_plaats; ?><!-- end temp -->
  56.         </li>
  57.         <li>
  58.             <?php echo CHtml::activeLabelEx($daytrip, 'Phone'); ?>
  59.             <?php echo CHtml::activeTextField($daytrip, 'Phone'); ?>
  60.         </li>
  61.         <li>
  62.             <?php echo CHtml::activeLabelEx($daytrip, 'Fax'); ?>
  63.             <?php echo CHtml::activeTextField($daytrip, 'Fax'); ?>
  64.         </li>
  65.         <li>
  66.             <?php echo CHtml::activeLabelEx($daytrip, 'Email'); ?>
  67.             <?php echo CHtml::activeTextField($daytrip, 'Email'); ?>
  68.         </li>
  69.         <li>
  70.             <?php echo CHtml::activeLabelEx($daytrip, 'Website'); ?>
  71.             <?php echo CHtml::activeTextField($daytrip, 'Website'); ?>
  72.             <?php echo CHtml::link('Ga', $daytrip->Website, array('target' => '_blank')); ?>
  73.         </li>
  74.         <li>
  75.             <?php echo CHtml::activeLabelEx($daytrip, 'YouTube'); ?>
  76.             <?php echo CHtml::activeTextField($daytrip, 'YouTube'); ?>
  77.             <?php echo CHtml::link('Ga', $daytrip->YouTube, array('target' => '_blank')); ?>
  78.         </li>
  79.         <li>
  80.             <fieldset>
  81.                 <legend><?php echo CHtml::activeLabelEx($daytrip, 'Categories'); ?></legend>
  82.                     <ol>
  83.                         <?php echo CHtml::activeCheckboxList($daytrip, 'Categories', CHtml::listData(Category::model()->findAll(), 'IdCategory', 'Category'), array('template' => '<li>{input} {label}</li>', 'separator' => '', 'checkAll' => 'Alle rubrieken')); ?>
  84.                     </ol>
  85.                     <!-- temp --><?php echo $daytrip->old_rubriek; ?><!-- end temp -->
  86.             </fieldset>
  87.         </li>
  88.         <li>
  89.             <?php echo CHtml::activeLabelEx($daytrip, 'Tags'); ?>
  90.             <?php $this->widget('CAutoComplete', $optionsTag); ?>
  91.             <!-- temp --><?php echo $daytrip->old_type; ?><!-- end temp -->
  92.         </li>
  93.         <li>
  94.             <?php echo CHtml::activeLabelEx($daytrip, 'Priority'); ?>
  95.             <?php echo CHtml::activeCheckBox($daytrip, 'Priority'); ?>
  96.         </li>
  97.         <li>
  98.             <?php echo CHtml::activeLabelEx($daytrip, 'Active'); ?>
  99.             <?php echo CHtml::activeRadioButtonList($daytrip, 'Active', array(0 => Yii::t('labels', 'No'), 1 => Yii::t('labels', 'Yes')), array('separator' => '')); ?>
  100.         </li>
  101.         <li>
  102.             <?php echo CHtml::submitButton(Yii::t('labels', $update ? 'Edit' : 'Save'), array('name' => 'submitDaytrip')); ?> of <?php echo CHtml::link('annuleer', array('daytrip/list')); ?>
  103.         </li>
  104.     </ol>
  105. </fieldset>
  106. <?php echo CHtml::endForm(); ?>
  107.  
  108. <script type="text/javascript">
  109. $(document).ready(function(){
  110.     $('#getAddress').click(function () {
  111.         var postcode = $('#Daytrip_ZipCode').val();
  112.         var number = $('#Daytrip_Number').val();
  113.         $.getJSON('http://6pp.kvdb.net/services/lookup?postcode='+escape(postcode)+'&streetnumber='+escape(number)+'&tg_format=json&jsonp=?',
  114.         function(json){
  115.             //alert(json.result[0].street + ', ' + json.result[0].city);
  116.             $('#Daytrip_Street').val(json.result[0].street);
  117.         });
  118.     });
  119.     $('#getZipCode').click(function () {
  120.         var street = $('#Daytrip_Street').val();
  121.         var number = $('#Daytrip_Number').val();
  122.         var city = $('#Daytrip_City').val();
  123.         $.getJSON('http://6pp.kvdb.net/services/getstreet?street='+escape(street)+'&city_name='+escape(city)+'&tg_format=json&jsonp=?',
  124.         function(json) {
  125.             $.each(json.result.streets, function(i, item) {
  126.                 if (number >= item.low && number <= item.high) {
  127.                     $('#Daytrip_ZipCode').val(item.fourpp + item.chars);
  128.                 } else if (item.low == null && item.high == null) {
  129.                     $('#Daytrip_ZipCode').val(item.fourpp + item.chars);
  130.                 }
  131.             });
  132.         });
  133.     });
  134. });
  135. </script>