کد:
                    echo '<div style="clear:both"></div></div>';          
                    echo '<div style="clear:both"></div></div>';                    
                }else if($fl->type=="selectlist"){
                    echo '<div style="margin:2px 0;">';
                        echo '<span style="text-align:right;display:inline-block;width:100px;margin:5px 10px 5px 0;float:left;" class="label">'.$fl->label.'</span>';
                        echo '<select name="'.$fl->name.'" '.$fl->params.' >';
                            $val = explode(';', $fl->values);
                                if($id>0){
                                    $def_value=$fl->value;     
                                }else{
                                    $def_value=$fl->default_value;
                                }
                        //        print_r($fl);die();
                            for($i=0;$i<count($val);$i++){
                                if($def_value==$val[$i]){
                                    $sel="selected";
                                }else{
                                    $sel="";
                                }
                                echo '<option '.$sel.' value="'.$val[$i].'">'.$val[$i].'</option>';
                            }
                            
                        echo '</select>';

                    echo '<div style="clear:both"></div></div>';                    
                }else if($fl->type=="radio"){
                    echo '<div style="margin:2px 0;">';
                        echo '<span style="text-align:right;display:inline-block;width:100px;margin:5px 10px 5px 0;float:left;" class="label">'.$fl->label.'</span>';                        
                        $val = explode(';', $fl->values);
                        echo '<div class="radiofield_box" style="float:left">';
                            for($i=0;$i<count($val);$i++){
                                $checked = '';
                                if($id>0){
                                    if($fl->value == $val[$i]){
                                        $checked = 'CHECKED';
                                    }                                         
                                }else{
                                    if($fl->default_value == $val[$i]){
                                        $checked = 'CHECKED';
                                    }                        
                                }
                                
                                echo '<div style="float:left;"><input type="radio" '.$checked.' value ="'.$val[$i].'" name="'.$fl->name.'" /><span class="radio_label" style="margin:5px 0px 0 10px;">'.$val[$i].'</span></div>';
                                echo '<div style="clear:both"></div>';
                            }    
                        echo '</div>';    
                        echo '<div style="clear:both"></div>';            
                    echo '</div>';    
                }else if($fl->type=="checkbox"){
                    echo '<div style="margin:2px 0;">';
                        echo '<span style="text-align:right;display:inline-block;width:100px;margin:5px 10px 5px 0;float:left;" class="label">'.$fl->label.'</span>';                        
                        $val = explode(';', $fl->values);
                        echo '<div class="radiofield_box" style="float:left">';
                            for($i=0;$i<count($val);$i++){
                                $checked = '';
                                if($id>0){                                    
                                    if(strstr($fl->value,';'.$val[$i].';' )){
                                        $checked = 'CHECKED';
                                    }                                         
                                }else{
                                    $def_val = explode(';', $fl->default_value);
                                    for($d=0;$d<count($def_val);$d++){
                                        if($def_val[$d] == $val[$i]){
                                            $checked = 'CHECKED';
                                        }                                            
                                    }
                    
                                }
                                
                                echo '<div style="float:left;"><input type="checkbox" '.$checked.' value ="'.$val[$i].'" name="'.$fl->name.'[]" /><span class="radio_label" style="margin:5px 0px 0 10px;vertical-align:middle;">'.$val[$i].'</span></div>';
                                echo '<div style="clear:both"></div>';
                            }    
                        echo '</div>';    
                        echo '<div style="clear:both"></div>';            
                    echo '</div>';    
                }else if($fl->type=="date"){
                     echo '<div style="margin:2px 0;" >';
                        echo '<span style="text-align:right;display:inline-block;width:100px;margin:5px 10px 5px 0;float:left;" class="label">'.$fl->label.'</span>';
                        echo '<input class="inputbox djcalendar" type="text" size="10" maxlenght="19" id="'.$fl->name.'" name="'.$fl->name.'" '.$fl->params; 
                        if($id>0){
                            echo ' value="'.$fl->value_date.'" ';     
                        }else{
                            if($fl->default_value=='current_date'){
                                echo ' value="'.date("Y-m-d").'" ';
                            }else{
                                echo ' value="'.$fl->default_value.'" ';    
                            }
                            
                        }
                        echo ' />';
                        echo ' <img class="calendar" src="templates/bluestork/images/system/calendar.png" alt="calendar" id="'.$fl->name.'button" />';
                        
                        /*                                            
                        echo '<script type="text/javascript">';
                        echo 'var startDate = new Date(2008, 8, 7);
                         Calendar.setup({
                            inputField  : "'.$fl->name.'",
                            ifFormat    : "%Y-%m-%d",                  
                            button      : "'.$fl->name.'button",
                            date      : startDate
                         });';
                        echo '</script>'; */
                        /*echo JHTML::calendar('2011-08-30', 'publish_down', 'publish_down', '%Y-%m-%d',
                                array('size'=>'12',
                                'maxlength'=>'10'));*/

                    echo '<div style="clear:both"></div></div>';                    
                }

             }                         
             die();
         }    
    }    
    
    public function save(){
        $app         = JFactory::getApplication();        
        $model         = $this->getModel('item');
        $row         = JTable::getInstance('Items', 'DJClassifiedsTable');        
        $par         = JComponentHelper::getParams( 'com_djclassifieds' );
        $db         = JFactory::getDBO();        
        $lang         = JFactory::getLanguage();
        $dispatcher = JDispatcher::getInstance();
        
                
        $row->bind(JRequest::get('post'));
        
            $row->description = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);
            $row->intro_desc = JRequest::getVar('intro_desc', '', 'post', 'string', JREQUEST_ALLOWRAW);
            $row->contact = nl2br(JRequest::getVar('contact', '', 'post', 'string'));
            if($row->alias){
                $row->alias = DJClassifiedsSEO::getAliasName($row->alias);
            }else{
                $row->alias = DJClassifiedsSEO::getAliasName($row->name);
            }

            $row->image_url = '';
                //$exp_date = explode('-', $_POST['date_expir']);
                //$exp_time = explode(':', $_POST['time_expir']);
            //$row->date_exp = mktime($exp_time[0],$exp_time[1],0,$exp_date[1],$exp_date[2],$exp_date[0]);
            $row->date_exp = $_POST['date_expir'].' '.$_POST['time_expir'].':00';
            
            $is_new=1;
            if($row->id>0){
                $old_date_exp = JRequest::getVar('date_exp_old','');
                if($old_date_exp != $row->date_exp){
                    $row->notify = 0;
                }
                $is_new=0;
            }
            
            if($row->id==0){
                $row->exp_days = ceil((strtotime($row->date_exp)-time())/(60*60*24));
            }
            
            if($row->user_id==0 && $row->id==0){
                $user=JFactory::getUser();
                $row->user_id = $user->id;
                $row->ip_address = $_SERVER['REMOTE_ADDR'];
            }
            
                $row->region_id= end($_POST['regions']);
                if(!$row->region_id){
                    $row->region_id =$_POST['regions'][count($_POST['regions'])-2];                    
                    if(!reset($_POST['regions'])){                    
                        $row->region_id=0;
                    }
                }
        
        
            if($row->id>0){    
                $query = "DELETE FROM #__djcf_fields_values WHERE item_id= ".$row->id." ";
                $db->setQuery($query);
                $db->query();

                if($row->payed==1){
                    $row->pay_type='';
                    $query = "UPDATE #__djcf_payments SET status='Completed' WHERE item_id= ".$row->id." AND type=0 ";
                    $db->setQuery($query);
                    $db->query();    
                }
            }