Example #1
0
 private function addMenuItem()
 {
     $title = $this->input->post('menuEditItem_plus');
     $url = url_title(transliteration($title), 'dash', TRUE);
     $owner = $this->session->userdata('user_id');
     $info = array('title' => $title, 'url_name' => $url, 'id_owner' => $owner);
     return $this->information_model->add_information($info);
 }
Example #2
0
 function planner_missed_events_export()
 {
     if ($this->input->is_ajax_request()) {
         $data_privileges = $this->template->get_data('privileges');
         $token = $this->session->userdata('token');
         $post_data = array('t' => $token, 'client_id' => $_POST['id']);
         $clients_details = server_data($this->config->item('api_url') . 'clients/details.php', $post_data);
         $notifies[] = $clients_details['result'];
         $data['client_info'] = $clients_details['response']['client_info'];
         $post_data = array('t' => $token, 'client_id' => $_POST['id'], 'date_start' => week_range($_POST['date_export_start'], 'start_day'), 'date_end' => week_range($_POST['date_export_end'], 'end_day'));
         $export = server_data($this->config->item('api_url') . 'planner/missed_events.php', $post_data);
         $data['client_events'] = $export['response']['data'];
         $notifies['success'] = $export['result']['notifies'];
         $this->template->set_data('planner_missed_events_export', $data);
         $this->template->load_file('clients/planner/planner_missed_events_export');
         $get_cookie_date = get_cookie('date');
         if (!empty($get_cookie_date)) {
             $event_date = get_cookie('date');
         } else {
             $event_date = date('d.m.Y');
         }
         if (is_not($export['result']['errors'])) {
             if ($export['result']['success'] == true) {
                 $file = 'Missed Events - ' . $clients_details['response']['client_info']['surname'] . ' ' . $clients_details['response']['client_info']['name'] . ' ' . week_range($_POST['date_export_start'], 'start_day') . ' - ' . week_range($_POST['date_export_end'], 'end_day');
                 echo json_encode(get_info('site_dir') . '/tmp/' . transliteration($file, FALSE) . '.docx');
             }
         } else {
             if (is($notifies)) {
                 $this->template->set_data('notifies', $notifies);
                 $this->template->load_file('notifies');
             }
         }
     } else {
         $this->error_404();
     }
 }
Example #3
0
/**
 * Импортирование продукта из xml
 * @param array $item
 * @param null $params
 * @return mixed
 */
function importPost(array $item, $params = NULL)
{
    /*
     * If connected woocommerce plugin - add posts to post type of woocommerce
     */
    include_once ABSPATH . 'wp-admin/includes/plugin.php';
    if (!is_plugin_active('woocommerce/woocommerce.php')) {
        echo "Для корректной работы этого плагина, необходимо установить Woocommerce плагин.";
        die;
    }
    $product_params = $params;
    global $wpdb;
    $rd_args = array('post_type' => 'product', 'meta_key' => 'offer_id', 'meta_value' => $item['id']);
    $q = new WP_Query($rd_args);
    $obItem = @$q->posts[0];
    //$obItem = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE ID = {$item['id']}");
    $postId = null;
    if (!empty($obItem->ID)) {
        if ($obItem->post_status == 'trash') {
            return;
        }
        if (!$obItem->post_modified || $obItem->post_date != $obItem->post_modified) {
            $item['title'] = $obItem->post_title;
            $item['description'] = $obItem->post_content;
        }
        $params = array('ID' => $obItem->ID, 'post_title' => $item['title'], 'post_content' => $item['description'], 'post_type' => 'product', 'post_name' => transliteration($item['title']));
        if (get_post_meta($obItem->ID, 'edited_by_user', TRUE)) {
            unset($params['post_title']);
            unset($params['post_content']);
            unset($params['post_name']);
        }
        wp_update_post($params);
        //set gdeslon offer_id
        update_post_meta($obItem->ID, 'offer_id', $item['id']);
        //set gdeslon url
        if ($item['url']) {
            update_post_meta($obItem->ID, 'url', $item['url'], get_post_meta($obItem->ID, 'url', TRUE));
        }
        //set gdeslon price
        if ($item['price']) {
            update_post_meta($obItem->ID, '_regular_price', $item['price'], get_post_meta($obItem->ID, '_regular_price', TRUE));
            update_post_meta($obItem->ID, '_price', $item['price'], get_post_meta($obItem->ID, '_price', TRUE));
            update_post_meta($obItem->ID, '_visibility', 'visible', get_post_meta($obItem->ID, '_visibility', TRUE));
            update_post_meta($obItem->ID, '_stock_status', 'instock', get_post_meta($obItem->ID, '_stock_status', TRUE));
        }
        $postId = $obItem->ID;
    } else {
        $postId = wp_insert_post(array('post_title' => $item['title'], 'post_content' => $item['description'], 'post_type' => 'product', 'post_status' => 'publish', 'post_mime_type' => $item['id'], 'comment_status' => 'closed', 'post_name' => transliteration($item['title'])));
        //set gdeslon offer_id
        add_post_meta($postId, 'offer_id', $item['id']);
        //set gdeslon url
        if ($item['url']) {
            add_post_meta($postId, 'url', $item['url'], TRUE);
        }
        //set gdeslon price
        if ($item['price']) {
            add_post_meta($postId, '_regular_price', $item['price'], TRUE);
            add_post_meta($postId, '_price', $item['price'], TRUE);
            add_post_meta($postId, '_visibility', 'visible', TRUE);
            add_post_meta($postId, '_stock_status', 'instock', TRUE);
        }
        add_post_meta($postId, '_wp_page_template', 'sidebar-page.php', TRUE);
    }
    /**
     * Подгрузка изображения
     */
    if (!empty($item['image'])) {
        download_image($item['image'], $postId);
    }
    wp_set_object_terms($postId, array(intval(get_category_by_outer_id($item['category_id'])->term_id)), 'product_cat');
    //add product params
    $attributes = array();
    unset($product_params['params_list']);
    unset($product_params['vendor']);
    foreach ($product_params as $name => $value) {
        $attributes[htmlspecialchars(stripslashes($name))] = array('name' => htmlspecialchars(stripslashes($name)), 'value' => $value, 'position' => 1, 'is_visible' => 1, 'is_variation' => 1, 'is_taxonomy' => 0);
    }
    set_product_attributes($postId, $attributes);
}