Plugin Directory

Changeset 3202662


Ignore:
Timestamp:
12/04/2024 09:15:57 PM (16 months ago)
Author:
universam
Message:

add plugin

Location:
universam-demo/trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • universam-demo/trunk/admin/assets/css/admin.css

    r3201974 r3202662  
    401401.mailing .modal__buttons{margin-top:10px}
    402402.mailing .usam_attachments{margin-top:5px; min-height:50px;}
    403 .mailing .usam_attachments .usam_attachments__file{display:-webkit-box; display:-ms-flexbox; display:flex; flex-direction:row;}
     403.mailing .usam_attachments .usam_attachments__file{display:-webkit-box; display:-ms-flexbox; display:flex; flex-direction:row; width:auto;}
    404404.mailing .usam_attachments img{max-height:50px;}
    405405.mailing .usam_attachments .attachment_icon{min-height:50px; max-width:50px; margin-right:10px}
     
    498498.usam_attachments .attachment_icon{min-height:120px; max-width:120px; display:flex; justify-content:center; align-items:center;}
    499499.usam_attachments img{max-height:120px; height:auto; width:100%;}
    500 .usam_attachments .filename{height: 12px; overflow: hidden;}
    501500.usam_attachments .attachment__file_data_download{margin-right:5px}
    502501.usam_attachments .loading_error{color:red;}
     
    14631462.modal .edit_form .edit_form__item_option{width:100%}
    14641463.page_sidebar img{max-width:100%;}
     1464.page_sidebar .edit_form .edit_form__item_option{width:100%}
    14651465@media screen and (min-width:1180px)
    14661466{
  • universam-demo/trunk/admin/assets/js/admin.js

    r3201974 r3202662  
    64196419                            data.description = t.getContent();
    64206420                    }
    6421                     console.log(data);
    64226421                    for (let i in this.sales_area)
    64236422                        data['sale_area_' + this.sales_area[i].id] = this.regions.includes(this.sales_area[i].id)
     
    84088407            },
    84098408            sms:{message:'', phone:0},
    8410             letter:{message:'',email:''},
    84118409            messenger:{message:'', type:''},
    84128410            sidebarActive:0
     
    84218419        this.scrollGrid();
    84228420    },
    8423     mounted() {
     8421     computed:{
     8422        subject() {
     8423            if ( this.object_id )
     8424            {
     8425                if( this.object_type == 'order' )
     8426                    return 'Сообщение о вашем заказе №'+this.object_id;
     8427                if( this.object_type == 'contacting' )
     8428                    return 'Ответ на обращение №'+this.object_id;
     8429            }
     8430            return '';
     8431        },
     8432     },
     8433    mounted() {
    84248434        this.upload();
    84258435        var el = document.querySelector('.js-show-more');
     
    84368446            });
    84378447            moreObserver.observe(el);
    8438         }
     8448        }       
    84398449    },
    84408450    methods:{
     
    96199629    props:{
    96209630        emails:{required:false, default:''},
     9631        subject:{type:String, required:false, default:''},
    96219632        attachments:{type:Array,required:false, default:() => []},
    96229633        object_type:{type:String, required:false, default:''},
     
    96289639            to:'',
    96299640            from:'',
    9630             subject:'',
     9641            title:this.subject,
    96319642            signatures:[],
    96329643            signature:'',
     
    96669677            for (i = 0; i < this.files.length; i++)
    96679678                files.push(this.files[i].id)
    9668                 usam_api('email/send', {mailbox_id:this.to, email:this.from,subject:this.subject, message:this.message, object_id:this.object_id, object_type:this.object_type, files:files}, 'POST', (r) => {
     9679                usam_api('email/send', {mailbox_id:this.to, email:this.from,subject:this.title, message:this.message, object_id:this.object_id, object_type:this.object_type, files:files}, 'POST', (r) => {
    96699680                    if (r) {
    96709681                        this.message = '';
    9671                         this.subject = '';
     9682                        this.title = '';
    96729683                        this.files = [];
    96739684                        this.$emit('add', r);
  • universam-demo/trunk/admin/assets/js/taxonomy/taxonomy.js

    r3201974 r3202662  
    148148                    categories:[], 
    149149                    category:0,
     150                    product_type:0,
    150151                    application_id:0
    151152                };
     
    154155                this.application_id = application_id;   
    155156                this.category = ozon_category; 
     157                this.product_type = ozon_product_type; 
    156158                usam_api('ozon/'+this.application_id+'/categories', 'GET', (r) => this.categories = r);
    157             }           
     159            },
     160            methods: {
     161                change(e)
     162                {
     163                    this.category = e.category_id; 
     164                    this.product_type = e.id;                       
     165                }
     166            }               
    158167        })         
    159168    }   
     
    161170
    162171Vue.component('ozon-categories', {     
    163     template: '<div><select-list @change="subcategory=$event.id" :lists="lists" :selected="subcategory"></select-list><ozon-categories-contents v-if="subcategory>0 && parentsCategories.length>0" @change="category=$event" :lists="parentsCategories" :selected="selected"/></div>',
     172    template: '<div><select-list @change="change" :lists="lists" :selected="subcategory"></select-list><ozon-categories v-if="subcategory>0 && parentsCategories.length>0" :lists="parentsCategories" @change="$emit(`change`, $event)" :selected="selected"/></div>',
    164173    props: {'lists': Array, 'selected': Number|String},
    165174    watch:{
     
    167176        {
    168177            if ( val )
    169                 this.subcategory = this.loadSubCategory( this.lists );
    170                
     178                this.subcategory = this.loadSubCategory( this.lists );             
    171179        }, 
    172180        lists(val, oldVal)
     
    174182            this.load();
    175183        },
    176         subcategory(val, oldVal)
    177         {
    178             if ( !this.parentsCategories.length )
    179                 this.$emit('change', val);
    180         }, 
    181         category(val, oldVal)
    182         {
    183             if ( this.parentsCategories.length )
    184                 this.$emit('change', val);
    185         }
    186184    },
    187185    computed: {     
     
    192190    },
    193191    data() {               
    194         return {subcategory:0, category:0}
     192        return {subcategory:0}
    195193    },
    196194    mounted()
     
    203201            if ( this.selected )
    204202                this.subcategory = this.loadSubCategory( this.lists );
     203        },
     204        change(e)
     205        {
     206            this.subcategory = e.id;   
     207            this.$emit('change', e);
    205208        },
    206209        loadSubCategory( lists )
     
    221224    }
    222225})
    223 Vue.component('ozon-categories-contents', {     
    224     template: '<div><ozon-categories @change="$emit(`change`, $event)" :lists="lists" :selected="selected"/></div>',
    225     props: {'lists': Array, 'selected': Number|String},
    226 })
  • universam-demo/trunk/admin/templates/template-parts/modal-panel/modal-panel-send_email.php

    r3133815 r3202662  
    22    <template v-slot:title><?php _e('Написать письмо', 'usam'); ?></template>
    33    <template v-slot:body="modalProps">     
    4         <send-email :emails="contact.emails" :object_id="object_id" :object_type="object_type" @add="addEmail" inline-template>
     4        <send-email :emails="contact.emails" :object_id="object_id" :object_type="object_type" @add="addEmail" :subject="subject" inline-template>
    55            <?php include( usam_get_filepath_admin('templates/template-parts/table_send_email.php') ); ?>
    66        </send-email>
  • universam-demo/trunk/admin/templates/template-parts/table_send_email.php

    r3133815 r3202662  
    1919    <tr>
    2020        <td class ='table_send_email__name'><?php _e('Тема', 'usam'); ?>:</td>
    21         <td><input type='text' v-model="subject" placeholder="Введите тему сообщения"></td>
     21        <td><input type='text' v-model="title" placeholder="Введите тему сообщения"></td>
    2222    </tr>           
    2323    <tr>
  • universam-demo/trunk/includes/integration/applications/moysklad.php

    r3201974 r3202662  
    29772977    }
    29782978   
    2979     public function save_options( )
     2979    public function save_options( $parameters )
    29802980    {   
    29812981        if ( $this->is_token() )
  • universam-demo/trunk/includes/integration/applications/ozon/ozon.php

    r3201974 r3202662  
    2020    }
    2121   
    22     public function format_categories( $categories )
     22    public function format_categories( $categories, $category_id = 0 )
    2323    {
    2424        $results = [];
     
    2626        {
    2727            $children = [];
     28            $category_id = isset($category['description_category_id']) ? $category['description_category_id'] : $category_id;
    2829            if( !empty($category['children']) )
    29                 $children = $this->format_categories( $category['children'] );
     30                $children = $this->format_categories( $category['children'], $category_id );
    3031            if( isset($category['description_category_id']) )
    31                 $results[] = ['id' => $category['description_category_id'], 'name' => $category['category_name'], 'children' => $children];
     32                $results[] = ['id' => $category['description_category_id'], 'category_id' => $category_id, 'name' => $category['category_name'], 'children' => $children];
    3233            else
    33                 $results[] = ['id' => $category['type_id'], 'name' => $category['type_name'], 'children' => $children];         
     34                $results[] = ['id' => $category['type_id'], 'category_id' => $category_id, 'name' => $category['type_name'], 'children' => $children];         
    3435        }       
    3536        return $results;
    3637    }
    3738   
     39    /*
     40    attribute_id    Идентификатор характеристики.
     41    description_category_id Идентификатор категории.
     42    last_value_id   Идентификатор справочника, с которого нужно начать ответ. Если last_value_id — 10, то в ответе будут справочники, начиная с одиннадцатого.
     43    limit   максимум — 5000, минимум — 1.
     44    type_id Идентификатор типа товара.
     45    */
     46    public function get_attribute_id( $query_vars = [] )
     47    {
     48        if( empty($query_vars['limit']) )
     49            $query_vars['limit'] = 5000;
     50        $args = $this->get_args( 'POST', $query_vars );
     51        $results = $this->send_request( "v1/description-category/attribute", $args );           
     52        if( isset($results['result']) )
     53            return $results['result'];
     54        return [];
     55    }
     56   
     57   
     58    public function get_ozon_attributes( $query_vars = [] )
     59    {
     60        if( empty($query_vars['limit']) )
     61            $query_vars['limit'] = 5000;
     62        $query_vars['language'] = 'RU';
     63        $args = $this->get_args( 'POST', $query_vars);
     64        $results = $this->send_request( "v1/description-category/attribute", $args );           
     65        if( isset($results['result']) )
     66            return $results['result'];
     67        return [];
     68    }   
     69           
    3870    public function update_products( $query_vars = [] )
    3971    {
     
    4274        $query_vars['order'] = 'ASC';
    4375        if ( !isset($query_vars['post_status']) )
    44             $query_vars['post_status'] = 'any';
    45        
     76            $query_vars['post_status'] = 'any'; 
     77        $items = [];
    4678        $products = usam_get_products( $query_vars );
    47         $category_ids = [];
    4879        foreach( $products as $key => $product )   
    49             $category_ids[] = $this->get_category_ozon( $product->ID );
    50        
    51         $args = $this->get_args( 'POST', ['attribute_type' => 'ALL', 'category_id' => $category_ids, 'language' => 'RU']);
    52         unset($category_ids);
    53         $ozon_attributes = $this->send_request( "v3/category/attribute", $args );       
    54         $items = [];
    55         foreach( $products as $key => $product )   
    56             $items[] = $this->get_ozon_product( $product, $ozon_attributes );
     80            $items[] = $this->get_ozon_product( $product );
    5781        $result = false;
    5882        if ( $items )
     
    80104   
    81105    //images, name, offer_id, price, vat   
    82     private function get_ozon_product( $product, $ozon_attributes = [] )
    83     {
     106    private function get_ozon_product( $product )
     107    {
     108        static $ozon_attributes = [];
    84109        if ( is_numeric($product) )
    85110            $product = get_post( $product );   
     
    98123            foreach ($urls as $url)
    99124                $insert['images'][] = $url;
    100         }   
    101         $category_ozon_id = $this->get_category_ozon( $product->ID );
    102         $insert['description_category_id'] = $category_ozon_id;     
    103         if ( $ozon_attributes )
     125        }
     126        extract( $this->get_category_ozon( $product->ID ));
     127       
     128        $insert['description_category_id'] = $ozon_category_id;
     129        $insert['type_id'] = $ozon_product_type;       
     130       
     131        if( empty($ozon_attributes[$ozon_product_type]) )
     132        {
     133            $ozon_attributes[$ozon_product_type] = $this->get_ozon_attributes(['description_category_id' => $ozon_category_id, 'type_id' => $ozon_product_type]);   
     134        }       
     135        if ( !empty($ozon_attributes[$ozon_product_type]) )
    104136        {
    105137            $product_attributes = usam_get_product_attributes_display( $product->ID, ['show_all' => true] );
    106             foreach ($ozon_attributes['result'] as $ozon_attrs)
    107             {              
    108                 if ( $category_ozon_id == $ozon_attrs['category_id'] )
    109                 {                  
    110                     foreach ($ozon_attrs['attributes'] as $ozon_attribute)
     138            foreach ($ozon_attributes[$ozon_product_type] as $ozon_attribute)
     139            {   
     140                foreach( $product_attributes as $attribute )
     141                {           
     142                    if ( $attribute['parent'] && $attribute['name'] == $ozon_attribute['name'] )
    111143                    {
    112                         foreach( $product_attributes as $attribute )
    113                         {                           
    114                             if ( $attribute['parent'] && $attribute['name'] == $ozon_attribute['name'] )
    115                             {
    116                                 $values = [];
    117                                 foreach( $attribute['value'] as $value )
    118                                     $values[] = ['dictionary_value_id' => 0, 'value' => $value];
    119                                 $insert['attributes'][] = ['complex_id' => 0, 'id' => $ozon_attribute['id'], 'values' => $values];
    120                             }
    121                         }
     144                        $values = [];
     145                        foreach( $attribute['value'] as $value )
     146                            $values[] = ['dictionary_value_id' => 0, 'value' => $value];
     147                        $insert['attributes'][] = ['complex_id' => 0, 'id' => $ozon_attribute['id'], 'values' => $values];
    122148                    }
    123149                }
     
    142168        if ( $length > 0 )
    143169            $insert['depth'] = $length;
    144         $insert['dimension_unit'] = get_option( 'usam_dimension_unit', 'mm' );     
    145        
    146        
    147         $Log = new USAM_Log_File( 'insert' );
    148     $Log->fwrite_array( $insert );
    149    
     170        $insert['dimension_unit'] = get_option( 'usam_dimension_unit', 'mm' ); 
    150171        return $insert;
    151172    }
     
    207228    private function get_category_ozon( $product_id )
    208229    {
    209         $category_ozon_id = (int)usam_get_product_meta( $product_id, 'category_ozon' );
    210         if ( $category_ozon_id > 0 )       
     230        $category_ozon_id = (int)usam_get_product_meta( $product_id, 'ozon_category' );
     231        if ( $category_ozon_id > 0 )   
     232        {
     233            $ozon_product_type = (int)usam_get_product_meta( $product_id, 'ozon_product_type' );
    211234            $category_id = $category_ozon_id;   
     235        }
    212236        else
    213237        {
    214             $terms = get_the_terms( $product_id, 'usam-category');             
     238            $terms = get_the_terms( $product_id, 'usam-category');              
    215239            $product_term_ids = [];
    216240            foreach( $terms as $term )
     
    220244                {
    221245                    $category_id = $ozon_category;
     246                    $ozon_product_type = (int)usam_get_term_metadata($term->term_id, 'ozon_product_type');
    222247                    break;
    223248                }
     
    231256                        {
    232257                            $category_id = $ozon_category;
     258                            $ozon_product_type = (int)usam_get_term_metadata($term_id, 'ozon_product_type');
    233259                            break;
    234260                        }
     
    236262                }           
    237263            }           
    238         }   
    239         return $category_id;
     264        }
     265        return ['ozon_category_id' => $category_id, 'ozon_product_type' => $ozon_product_type];
    240266    }
    241267   
     
    294320                ['field_type' => 'text', 'name' => 'Client ID', 'code' => 'login', 'default' => ''],
    295321                ['field_type' => 'password', 'name' => 'API key', 'code' => 'access_token', 'default' => ''],   
    296                 ['field_type' => 'html', 'name' => 'API key', 'code' => '', 'default' => rest_url($this->namespace.'/'.$this->option['service_code'].'/'.$this->option['id'].'/notifications')],               
     322                //['field_type' => 'html', 'name' => 'Ссылка', 'code' => '', 'default' => rest_url($this->namespace.'/'.$this->option['service_code'].'/'.$this->option['id'].'/notifications')],               
    297323            ]],
    298324            ['name' => __('Обновление товаров', 'usam'), 'code' => 'product', 'options' => [           
     
    309335    }
    310336   
    311     public function save_options( )
     337    public function save_options( $parameters )
    312338    {       
    313339        $this->remove_hook( 'update_stock' );           
     
    325351    public function save_category_form( $term_id, $tt_id )
    326352    {
    327         if ( isset($_POST['ozon_category'] ) )
     353        if ( isset($_POST['ozon_category']) && isset($_POST['ozon_product_type']) )
     354        {
    328355            usam_update_term_metadata($term_id, 'ozon_category', absint($_POST['ozon_category']));
     356            usam_update_term_metadata($term_id, 'ozon_product_type', absint($_POST['ozon_product_type']));
     357        }
    329358    }   
    330359   
     
    335364            <script>           
    336365                var application_id = <?php echo $this->id; ?>;         
    337                 var ozon_category = <?php echo (int)usam_get_term_metadata($tag->term_id, 'ozon_category'); ?>;                 
     366                var ozon_category = <?php echo (int)usam_get_term_metadata($tag->term_id, 'ozon_category'); ?>;         
     367                var ozon_product_type = <?php echo (int)usam_get_term_metadata($tag->term_id, 'ozon_product_type'); ?>;                 
    338368            </script>   
    339369            <?php           
     
    341371        ?>     
    342372        <tr id="ozon_categories" class="form-field">
    343             <th scope="row" valign="top"><?php esc_html_e( 'Категория Ozon', 'usam'); ?><input type='hidden' name="ozon_category" v-model="category"></th>
     373            <th scope="row" valign="top"><?php esc_html_e( 'Категория Ozon', 'usam'); ?><input type='hidden' name="ozon_category" v-model="category"><input type='hidden' name="ozon_product_type" v-model="product_type">category={{category}} product_type={{product_type}}</th>
    344374            <td>
    345                 <div><ozon-categories @change="category=$event" :lists="categories" :selected="category"/></div>                                   
     375                <div><ozon-categories @change="change" :lists="categories" :selected="product_type"/></div>                                 
    346376            </td>           
    347377        </tr>           
  • universam-demo/trunk/includes/integration/applications/vavto.php

    r3201974 r3202662  
    444444    }
    445445   
    446     public function save_options( )
     446    public function save_options( $parameters )
    447447    {       
    448448        $this->remove_hook( 'update' );
  • universam-demo/trunk/includes/integration/applications/wildberries/wildberries.php

    r3201974 r3202662  
    193193    }
    194194   
    195     public function save_options( )
     195    public function save_options( $parameters )
    196196    {       
    197197        $this->remove_hook( 'update_stock' );           
  • universam-demo/trunk/includes/integration/applications/yandexmarket/yandexmarket.php

    r3201974 r3202662  
    352352    }
    353353   
    354     public function save_options( )
     354    public function save_options( $parameters )
    355355    {       
    356356        $this->remove_hook( 'update_stock' );           
  • universam-demo/trunk/includes/mailings/email.class.php

    r3186033 r3202662  
    544544        $attachments_filepath = array();
    545545        foreach ( $attachments as $attachment )
    546             $attachments_filepath[$attachment->title.'.'.pathinfo(USAM_UPLOAD_DIR.$attachment->file_path, PATHINFO_EXTENSION)] = USAM_UPLOAD_DIR.$attachment->file_path;           
     546            $attachments_filepath[$attachment->title] = USAM_UPLOAD_DIR.$attachment->file_path;         
    547547        //$to_email получатель письма
    548548        $email_sent = wp_mail( $to_email, $title, $message, $headers, $attachments_filepath ); 
  • universam-demo/trunk/includes/mailings/send_newsletter.class.php

    r3201974 r3202662  
    4545            foreach ( $files as $file )
    4646            {       
    47                 $attachments[$file->title.'.'.pathinfo(USAM_UPLOAD_DIR.$file->file_path, PATHINFO_EXTENSION)] = USAM_UPLOAD_DIR.$file->file_path;
     47                $attachments[$file->title] = USAM_UPLOAD_DIR.$file->file_path;
    4848            }
    4949            $rule_ids = usam_get_array_metadata($this->mailing['id'], 'newsletter', 'pricelist');
  • universam-demo/trunk/theme/usam-global-style.css

    r3201974 r3202662  
    331331.usam_chat_contact_form__info{padding:0 5px;}
    332332.modal{display:none; position:fixed; top:10%; left:50%; -webkit-transform:translate(-50%, 0%); -ms-transform:translate(-50%, 0%); transform:translate(-50%, 0%); z-index:100001; background-color:#ffffff; border:1px solid rgba(0, 0, 0, 0.3); *border:1px solid #999; border-radius:var(--radius); outline:none; -webkit-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3); box-shadow:0 3px 7px rgba(0, 0, 0, 0.3); -webkit-background-clip:padding-box; -moz-background-clip:padding-box; background-clip:padding-box; overflow:hidden;}
    333 .modal.in{display:block}
     333.modal.in{display:block!important}
    334334.modal .close{font-size:20px; color:#000000; opacity:0.2; filter:alpha(opacity=20); cursor:pointer; position:absolute; z-index:10; right:10px; top:50%; transform:translate(0,-50%); }
    335335.modal .close:hover,
  • universam-demo/trunk/universam.php

    r3201974 r3202662  
    44 * Plugin URI: https://wp-universam.ru
    55 * Description: Платформа для управления бизнесом и интернет-магазином. Встроенный парсинг, CRM, соц. сети, мессенджеры, карты, план продаж, управление остатками, контакт-центр, коммерческие предложения, счета, акты, инструменты для продвижения сайта, конструктор отчетов, файлы, рассылки, СМС.
    6  * Version: 8.64
     6 * Version: 8.64.3
    77 * Author: universam
    88 * Author URI: https://wp-universam.ru
     
    1616{   
    1717    protected static $_instance = null;
    18     private          $version = '8.64';
     18    private          $version = '8.64.3';
    1919    public function __construct()
    2020    {
Note: See TracChangeset for help on using the changeset viewer.