Guest User

Untitled

a guest
Apr 4th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.51 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * Handle the waitinglist
  5. *
  6. * @package  VirtueMart
  7. * @subpackage Product
  8. * @author RolandD
  9. * @link http://www.virtuemart.net
  10. * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
  11. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  12. * VirtueMart is free software. This version may have been modified pursuant
  13. * to the GNU General Public License, and as distributed it includes or
  14. * is derivative of works licensed under the GNU General Public License or
  15. * other free or open source software licenses.
  16. * @version $Id: product_edit_waitinglist.php 2978 2011-04-06 14:21:19Z alatak $
  17. */
  18.  
  19. // Check to ensure this file is included in Joomla!
  20. defined('_JEXEC') or die('Restricted access');
  21. if (isset($this->product->customfields_fromParent)) { ?>
  22.     <label><?php echo JText::_('COM_VIRTUEMART_CUSTOM_SAVE_FROM_CHILD');?><input type="checkbox" name="save_customfields" value="1" /></label>
  23. <?php } else {
  24.     ?> <input type="hidden" name="save_customfields" value="1" />
  25. <?php }  ?>
  26. <table id="customfieldsTable" width="100%">
  27.     <tr>
  28.         <td valign="top" width="%100">
  29.  
  30.         <?php
  31.             $i=0;
  32.             $tables= array('categories'=>'','products'=>'','fields'=>'','customPlugins'=>'',);
  33.             if (isset($this->product->customfields)) {
  34.                 foreach ($this->product->customfields as $customfield) {
  35.                     if ($customfield->is_cart_attribute) $cartIcone=  'default';
  36.                     else  $cartIcone= 'default-off';
  37.                     if ($customfield->field_type == 'Z') {
  38.  
  39.                         $tables['categories'] .=  '
  40.                             <div class="vm_thumb_image">
  41.                                 <span>'.$customfield->display.'</span>'.
  42.                                 VirtueMartModelCustomfields::setEditCustomHidden($customfield, $i)
  43.                               .'<div class="vmicon vmicon-16-remove"></div>
  44.                             </div>';
  45.  
  46.                     } elseif ($customfield->field_type == 'R') {
  47.  
  48.                         $tables['products'] .=  '
  49.                             <div class="vm_thumb_image">
  50.                                 <span>'.$customfield->display.'</span>'.
  51.                                 VirtueMartModelCustomfields::setEditCustomHidden($customfield, $i)
  52.                               .'<div class="vmicon vmicon-16-remove"></div>
  53.                             </div>';
  54.  
  55.                     } elseif ($customfield->field_type == 'G') {
  56.                         // no display (group of) child , handled by plugin;
  57.                     } elseif ($customfield->field_type == 'E'){
  58.                         $tables['fields'] .= '<tr class="removable">
  59.                             <td>'.JText::_($customfield->custom_title).'</td>
  60.                             <td>'.$customfield->custom_tip.'</td>
  61.                             <td>'.$customfield->display.'</td>'.
  62.                             VirtueMartModelCustomfields::setEditCustomHidden($customfield, $i)
  63.                             .'</td>
  64.                             <td>'.JText::_('COM_VIRTUEMART_CUSTOM_EXTENSION').'</td>
  65.                             <td>
  66.                             <span class="vmicon vmicon-16-'.$cartIcone.'"></span>
  67.                             </td>
  68.                             <td><span class="vmicon vmicon-16-remove"></span><input class="ordering" type="hidden" value="'.$customfield->ordering.'" name="field['.$i .'][ordering]" /></td>
  69.                          </tr>';
  70.                         /*$tables['fields'] .= '
  71.                             <tr class="removable">
  72.                                 <td>'.JText::_($customfield->custom_title).'</td>
  73.                                 <td colspan="3"><span>'.$customfield->display.$customfield->custom_tip.'</span>'.
  74.                                 VirtueMartModelCustomfields::setEditCustomHidden($customfield, $i)
  75.                               .'</td><span class="vmicon icon-nofloat vmicon-16-'.$cartIcone.'"></span>
  76.                                 <span class="vmicon vmicon-16-remove"></span>
  77.                             </tr>';*/
  78.                     } else {
  79.                         $tables['fields'] .= '<tr class="removable">
  80.                             <td>'.JText::_($customfield->custom_title).'</td>
  81.                             <td>'.$customfield->custom_tip.'</td>
  82.                             <td>'.$customfield->display.'</td>
  83.                             <td>'.JText::_($this->fieldTypes[$customfield->field_type]).
  84.                             VirtueMartModelCustomfields::setEditCustomHidden($customfield, $i)
  85.                             .'</td>
  86.                             <td>
  87.                             <span class="vmicon vmicon-16-'.$cartIcone.'"></span>
  88.                             </td>
  89.                             <td><span class="vmicon vmicon-16-remove"></span><input class="ordering" type="hidden" value="'.$customfield->ordering.'" name="field['.$i .'][ordering]" /></td>
  90.                          </tr>';
  91.                         }
  92.  
  93.                     $i++;
  94.                 }
  95.             }
  96.  
  97.              $emptyTable = '
  98.                 <tr>
  99.                     <td colspan="7">'.JText::_( 'COM_VIRTUEMART_CUSTOM_NO_TYPES').'</td>
  100.                 <tr>';
  101.             ?>
  102.             <fieldset style="background-color:#F9F9F9;">
  103.                 <legend><?php echo JText::_('COM_VIRTUEMART_RELATED_CATEGORIES'); ?></legend>
  104.                 <?php echo JText::_('COM_VIRTUEMART_CATEGORIES_RELATED_SEARCH'); ?>
  105.                 <div class="jsonSuggestResults" style="width: auto;">
  106.                     <input type="text" size="40" name="search" id="relatedcategoriesSearch" value="" />
  107.                     <button class="reset-value"><?php echo JText::_('COM_VIRTUEMART_RESET') ?></button>
  108.                 </div>
  109.                 <div id="custom_categories"><?php echo  $tables['categories']; ?></div>
  110.             </fieldset>
  111.             <fieldset style="background-color:#F9F9F9;">
  112.                 <legend><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?></legend>
  113.                 <?php echo JText::_('COM_VIRTUEMART_PRODUCT_RELATED_SEARCH'); ?>
  114.                 <div class="jsonSuggestResults" style="width: auto;">
  115.                     <input type="text" size="40" name="search" id="relatedproductsSearch" value="" />
  116.                     <button class="reset-value"><?php echo JText::_('COM_VIRTUEMART_RESET') ?></button>
  117.                 </div>
  118.                 <div id="custom_products"><?php echo  $tables['products']; ?></div>
  119.             </fieldset>
  120.  
  121.             <fieldset style="background-color:#F9F9F9;">
  122.                 <legend><?php echo JText::_('COM_VIRTUEMART_CUSTOM_FIELD_TYPE' );?></legend>
  123.                 <div><?php echo  '<div class="inline">'.$this->customsList; ?>test</div>
  124.                 <div> <?php //echo $this->customsList ; ?> </div>
  125.  
  126.                 <table id="custom_fields" class="adminlist" cellspacing="0" cellpadding="0">
  127.                     <thead>
  128.                     <tr class="row1">
  129.                         <th><?php echo JText::_('COM_VIRTUEMART_TITLE');?></th>
  130.                         <th><?php echo JText::_('COM_VIRTUEMART_CUSTOM_TIP');?></th>
  131.                         <th><?php echo JText::_('COM_VIRTUEMART_VALUE');?></th>
  132.                         <th><?php echo JText::_('COM_VIRTUEMART_CART_PRICE');?></th>
  133.                         <th><?php echo JText::_('COM_VIRTUEMART_TYPE');?></th>
  134.                         <th><?php echo JText::_('COM_VIRTUEMART_CUSTOM_IS_CART_ATTRIBUTE');?></th>
  135.                         <th><?php echo JText::_('COM_VIRTUEMART_DELETE'); ?></th>
  136.                         <th>test</th>
  137.                     </tr>
  138.                     </thead>
  139.                     <tbody id="custom_field">
  140.                         <?php
  141.                         if ($tables['fields']) echo $tables['fields'] ;
  142.                         else echo $emptyTable;
  143.                        
  144.                        
  145.                        
  146.                         ?>
  147.    
  148.                        
  149.                                                
  150.                     </tbody>
  151.                 </table><!-- custom_fields -->
  152.             </fieldset>
  153.             <!--fieldset style="background-color:#F9F9F9;">
  154.                 <legend><?php echo JText::_('COM_VIRTUEMART_CUSTOM_EXTENSION'); ?></legend>
  155.                 <div id="custom_customPlugins"><?php echo  $tables['customPlugins']; ?></div>
  156.             </fieldset-->
  157.         </td>
  158.  
  159.     </tr>
  160. </table>
  161.  
  162.  
  163. <div style="clear:both;"></div>
  164.  
  165.  
  166. <script type="text/javascript">
  167.     nextCustom = <?php echo $i ?>;
  168.  
  169.     jQuery(document).ready(function(){
  170.         jQuery('#custom_field').sortable();
  171.         // Need to declare the update routine outside the sortable() function so
  172.         // that it can be called when adding new customfields
  173.         jQuery('#custom_field').bind('sortupdate', function(event, ui) {
  174.             jQuery(this).find('.ordering').each(function(index,element) {
  175.                 jQuery(element).val(index);
  176.                 //console.log(index+' ');
  177.  
  178.             });
  179.         });
  180.     });
  181.     jQuery('select#customlist').chosen().change(function() {
  182.         selected = jQuery(this).find( 'option:selected').val() ;
  183.         jQuery.getJSON('index.php?option=com_virtuemart&view=product&task=getData&format=json&type=fields&id='+selected+'&row='+nextCustom+'&virtuemart_product_id=<?php echo $this->product->virtuemart_product_id; ?>',
  184.         function(data) {
  185.             jQuery.each(data.value, function(index, value){
  186.                 jQuery("#custom_field").append(value);
  187.                 jQuery('#custom_field').trigger('sortupdate');
  188.             });
  189.         });
  190.         nextCustom++;
  191.     });
  192.  
  193.         jQuery('input#relatedproductsSearch').autocomplete({
  194.  
  195.         source: 'index.php?option=com_virtuemart&view=product&task=getData&format=json&type=relatedproducts&row='+nextCustom,
  196.         select: function(event, ui){
  197.             jQuery("#custom_products").append(ui.item.label);
  198.             nextCustom++;
  199.             jQuery(this).autocomplete( "option" , 'source' , 'index.php?option=com_virtuemart&view=product&task=getData&format=json&type=relatedproducts&row='+nextCustom )
  200.             jQuery('input#relatedproductsSearch').autocomplete( "option" , 'source' , 'index.php?option=com_virtuemart&view=product&task=getData&format=json&type=relatedproducts&row='+nextCustom )
  201.         },
  202.         minLength:1,
  203.         html: true
  204.     });
  205.     jQuery('input#relatedcategoriesSearch').autocomplete({
  206.  
  207.         source: 'index.php?option=com_virtuemart&view=product&task=getData&format=json&type=relatedcategories&row='+nextCustom,
  208.         select: function(event, ui){
  209.             jQuery("#custom_categories").append(ui.item.label);
  210.             nextCustom++;
  211.             jQuery(this).autocomplete( "option" , 'source' , 'index.php?option=com_virtuemart&view=product&task=getData&format=json&type=relatedcategories&row='+nextCustom )
  212.             jQuery('input#relatedcategoriesSearch').autocomplete( "option" , 'source' , 'index.php?option=com_virtuemart&view=product&task=getData&format=json&type=relatedcategories&row='+nextCustom )
  213.         },
  214.         minLength:1,
  215.         html: true
  216.     });
  217.     // jQuery('#customfieldsTable').delegate('td','click', function() {
  218.         // jQuery('#customfieldsParent').remove();
  219.         // jQuery(this).undelegate('td','click');
  220.     // });
  221.     // jQuery.each(jQuery('#customfieldsTable').filter(":input").data('events'), function(i, event) {
  222.         // jQuery.each(event, function(i, handler){
  223.         // console.log(handler);
  224.       // });
  225.     // });
  226.  
  227.  
  228. eventNames = "click.remove keydown.remove change.remove focus.remove"; // all events you wish to bind to
  229.  
  230. function removeParent() {jQuery('#customfieldsParent').remove();console.log($(this));//jQuery('#customfieldsTable input').unbind(eventNames, removeParent)
  231.  }
  232.  
  233. // jQuery('#customfieldsTable input').bind(eventNames, removeParent);
  234.  
  235.   // jQuery('#customfieldsTable').delegate('*',eventNames,function(event) {
  236.     // var $thisCell, $tgt = jQuery(event.target);
  237.     // console.log (event);
  238.     // });
  239.         jQuery('#customfieldsTable').find('input').each(function(i){
  240.             current = jQuery(this);
  241.         // var dEvents = curent.data('events');
  242.         // if (!dEvents) {return;}
  243.  
  244.         current.click(function(){
  245.                 jQuery('#customfieldsParent').remove();
  246.             });
  247.         //console.log (curent);
  248.         // jQuery.each(dEvents, function(name, handler){
  249.             // if((new RegExp('^(' + (events === '*' ? '.+' : events.replace(',','|').replace(/^on/i,'')) + ')$' ,'i')).test(name)) {
  250.                // jQuery.each(handler, function(i,handler){
  251.                    // outputFunction(elem, '\n' + i + ': [' + name + '] : ' + handler );
  252.  
  253.  
  254.                // });
  255.            // }
  256.         // });
  257.     });
  258.  
  259.     //onsole.log(jQuery('#customfieldsTable').data('events'));
  260.  
  261. </script>
Advertisement
Add Comment
Please, Sign In to add comment