Пример #1
0
function nzshpcrt_getproductform($prodid)
{
    global $wpdb, $nzshpcrt_imagesize_info, $current_user;
    /*
     * makes the product form
     * has functions inside a function
     */
    //$sql = "SELECT * FROM `wp_product_list` WHERE `id`=$prodid LIMIT 1";
    $sql = "SELECT wp_product_list.*, wp_product_files.width, wp_product_files.height, wp_product_files.mimetype FROM wp_product_list, wp_product_files WHERE wp_product_files.id=wp_product_list.file AND wp_product_list.id={$prodid} LIMIT 1";
    $product_data = $wpdb->get_results($sql, ARRAY_A);
    $product = $product_data[0];
    /* 
     * for security reason add to url for hires images sid - last 6 simbols of idhash
     *
     */
    $sql = "SELECT `idhash` FROM `wp_product_files` WHERE `id`=" . $product['file'];
    $idhash_data = $wpdb->get_results($sql, ARRAY_A);
    if ($idhash_data != null) {
        $idhash = "&sid=" . substr($idhash_data[0]['idhash'], -6);
    }
    $output = "<table>\n\r";
    $output .= "<tr>\n\r";
    $output .= "<td class='r'>";
    $output .= "Автор: ";
    $output .= "</td>\n\r";
    $output .= "<td>\n\r";
    $output .= brandslist($product['brand']);
    $approved = 0;
    //pokazh($product,"product: ");
    //pokazh($current_user);
    if ($product['approved'] == '1') {
        $approved = " checked='checked'";
        if (isset($current_user->wp_capabilities['administrator']) && $current_user->wp_capabilities['administrator'] == 1) {
            $output .= "<input type='checkbox' name='approved'" . $approved . "/> Утверждено.";
        } else {
            if (isset($current_user->wp_capabilities['editor']) && $current_user->wp_capabilities['editor'] == 1) {
                $output .= "<input type='checkbox' name='approved'" . $approved . "/> Утвержено.";
            }
        }
        $output .= "<div style='color:#669900'>Картинка находится в <b>хранилище банка</b></div>";
    } elseif ($product['approved'] == '0') {
        $approved = "";
        if (isset($current_user->wp_capabilities['administrator']) && $current_user->wp_capabilities['administrator'] == 1) {
            $output .= "<input type='checkbox' name='approved'" . $approved . "/> Утверждено.";
        }
        $output .= "<div style='color:#9900CC'>Картинка может находиться в <b>Рабочем столе</b></div>";
    } else {
        $approved = "";
        if (isset($current_user->wp_capabilities['administrator']) && $current_user->wp_capabilities['administrator'] == 1) {
            $output .= "<input type='checkbox' name='approved'" . $approved . "/> Утверждено.";
        }
        $output .= "<div style='color:#FF6600'>Картинка находится в <b>прихожей банка</b> в ожидании приёма</div>";
    }
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    $output .= "<tr>\n\r";
    $output .= "<td class='r'>";
    $output .= "Название рисунка: ";
    $output .= "</td>\n\r";
    $output .= "<td>";
    $output .= "<input id='productnameedit' type='text' style='width:300px;' name='title' value='" . stripslashes($product['name']) . "' /> # <a href='" . SITEURL . "/?page_id=29&cartoonid=" . $product['id'] . "' target=_blank>" . $product['id'] . "</a>";
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    $output .= "<tr>\n\r";
    $output .= "<td class='r'>";
    $output .= "Краткое описание: ";
    $output .= "</td>\n\r";
    $output .= "<td>";
    $output .= "<textarea id='productdescredit' name='description' cols='50' rows='4' >" . stripslashes($product['description']) . "</textarea>";
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    $output .= "<tr>\n\r";
    $output .= "<td class='r'>";
    $output .= "Ключевые слова,<br />разделённые запятыми:<br>";
    $output .= "<a href='" . SITEURL . "/ales/wordassociations/words.php?id=" . $product['id'] . "' target=_blank>добавить<br>ассоциаций</a>";
    $output .= "</td>\n\r";
    $output .= "<td>";
    $output .= "<textarea id='tagsedit' name='additional_description' cols='50' rows='4' >" . stripslashes($product['additional_description']) . "</textarea>";
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    $visible = "";
    if ($product['visible'] == '1') {
        $visible = " checked='checked'";
    }
    $output .= "<tr>\n\r";
    $output .= "</tr>\n\r";
    if (isset($current_user->wp_capabilities['administrator']) && $current_user->wp_capabilities['administrator'] == 1) {
        $output .= "<tr>\n\r";
        $output .= "<td class='r'>";
        $output .= "Видно всем:";
        $output .= "</td>\n\r";
        $output .= "<td>";
        $output .= "<input type='checkbox' name='visible'" . $visible . "/> <span style='color:#999;'>Если выключить — не будет видно покупателям</span>";
        $output .= "</td>\n\r";
        $output .= "</tr>\n\r";
    }
    $colored = "";
    if ($product['color'] == '1') {
        $colored = " checked='checked' ";
    }
    $temadnya = "";
    $istemadnya_sql = "SELECT * FROM `wp_item_category_associations` where `category_id` = '777' and `product_id` = " . $product['id'];
    //pokazh ($istemadnya_sql);
    $istemadnya = $wpdb->get_results($istemadnya_sql);
    if ($istemadnya != null) {
        $temadnya = " checked='checked' ";
    }
    //pokazh($istemadnya,"istemadnya: ");
    $not_for_sale = "";
    if ($product['not_for_sale'] == '1') {
        $not_for_sale = " checked='checked' ";
    }
    $license1checked = "";
    if ($product['l1_price'] != '0') {
        $license1checked = " checked='checked' ";
    }
    $license2checked = "";
    if ($product['l2_price'] != '0') {
        $license2checked = " checked='checked' ";
    }
    $license3checked = "";
    if ($product['l3_price'] != '0') {
        $license3checked = " checked='checked' ";
    }
    $output .= "<tr>\n\r";
    $output .= "<td class='ralt'>";
    $output .= "Цветной рисунок:";
    $output .= "</td>\n\r";
    $output .= "<td style='background-color:#FFFF33;'>";
    $output .= "<input type='checkbox' name='colored'" . $colored . "/> <span style='color:#999;'>Отключите для ч/б рисунков</span>";
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    $output .= "<tr>\n\r";
    $output .= "<td class='r'>";
    $output .= "Не для продажи:";
    $output .= "</td>\n\r";
    $output .= "<td>\n\r";
    $output .= "<input type='checkbox' name='not_for_sale'" . $not_for_sale . "/> <span style='color:#999;'>Не продаётся, если включено</span>";
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    $output .= "<tr>\n\r";
    $output .= "<td>";
    $basepath = str_replace("/wp-admin", "", getcwd());
    if (file_exists($basepath . "/wp-content/plugins/wp-shopping-cart/product_images/" . $product['image'])) {
        $image_location = "product_images/" . $product['image'];
    } else {
        $image_location = "images/" . $product['image'];
    }
    $preview_location = "product_images/" . $product['image'];
    $icon_location = "images/" . $product['image'];
    $m_image_link = SITEURL . "/wp-content/plugins/wp-shopping-cart/" . $preview_location;
    $output .= "<a href='" . $m_image_link . "' target=_blank><img id='previewimage' src='" . SITEURL . "/wp-content/plugins/wp-shopping-cart/{$icon_location}' alt='" . TXT_WPSC_PREVIEW . "' title='" . TXT_WPSC_PREVIEW . "' /></a>";
    $output .= "Ш х В: " . $product['width'] . "x" . $product['height'] . "<br>" . $product['mimetype'];
    $output .= "</td>\n\r";
    $output .= "<td>\n\r";
    $output .= categorylist($product['id']);
    /*
    if (isset($current_user->wp_capabilities['administrator']) && $current_user->wp_capabilities['administrator']==1)
    	{
    		$output .= categorylist($product['id']);
    	}
    else
    	{
    		$output .= "После утверждения рисунка модераторами Категория может быть изменена администратором";
    		$output .= "<div  style='display:none;'>".categorylist($product['id'])."</div>";
    	}
    */
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    $output .= "<tr>\n\r";
    $output .= "<td class='ralt'>";
    $output .= "Тема дня::";
    $output .= "</td>\n\r";
    $output .= "<td class='lalt'>";
    $output .= "<input type='checkbox' name='temadnya'" . $temadnya . "/> <span style='color:#999;'>считаю актуальной темой</span>";
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    //if (isset($current_user->wp_capabilities['administrator']) && $current_user->wp_capabilities['administrator']==1){
    $output .= "<tr>\n\r";
    $output .= "<td class='r'>";
    $output .= "Доступны лицензии:";
    $output .= "</td>\n\r";
    $output .= "<td>\n\r";
    $output .= "&nbsp;&nbsp;&nbsp;Огр:&nbsp;<input id='license1' type='checkbox' name='license1'" . $license1checked . ">&nbsp;&nbsp;&nbsp;Станд:&nbsp;<input id='license2' type='checkbox' name='license2'" . $license2checked . ">&nbsp;&nbsp;&nbsp;Расш:&nbsp;<input id='license3' type='checkbox' name='license3'" . $license3checked . "><br />";
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    //}
    $output .= "<tr>\n\r";
    $output .= "<td colspan='2'>";
    if (isset($current_user->wp_capabilities['administrator']) && $current_user->wp_capabilities['administrator'] == 1) {
        $output .= "<a href='admin.php?page=wp-shopping-cart/display-items.php&amp;deleteid=" . $product['id'] . "' onclick='return conf();'><img src='../img/trash.gif' title='удалить'></a>";
    }
    $output .= "<a  href='admin.php?page=wp-shopping-cart/display-items.php&updateimage=" . $product['id'] . "' ><img src='" . SITEURL . "/img/reload.gif' title='Обновить иконку и слайд с водяными знаками'></a>";
    $output .= "&nbsp;<a href='index.php?admin_preview=true&product_id=" . $product['id'] . $idhash . "' style='float: left;' ><img src='http://th.cartoonbank.ru/download.gif' title='Скачать оригинальный файл' /></a>";
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    // download original image
    if ($product['file'] > 0) {
        if (is_numeric($product['file']) && $product['file'] > 0) {
            $file_data = $wpdb->get_results("SELECT * FROM `wp_product_files` WHERE `id`='" . $product['file'] . "' LIMIT 1", ARRAY_A);
            if ($file_data != null && $file_data[0]['mimetype'] == 'audio/mpeg' && function_exists('listen_button')) {
                $output .= "&nbsp;&nbsp;&nbsp;" . listen_button($file_data[0]['idhash']);
            }
        }
        $output .= "</td>\n\r";
        $output .= "</tr>\n\r";
        $output .= "<tr>\n\r";
        $output .= "<td class='r'>";
        $output .= "Заменить файл:";
        $output .= "</td>\n\r";
        $output .= "<td>\n\r";
        $output .= "<input type='file' name='file' value='' /> <div style='color:#999;'>Это тот файл, ссылка на который<br />будет отправлена заказчику</div>";
        $output .= "</td>\n\r";
        $output .= "</tr>\n\r";
    }
    $output .= "<tr>\n\r";
    $output .= "<td>\n\r";
    $output .= "</td>\n\r";
    $output .= "<td>\n\r";
    $output .= "<input type='hidden' name='prodid' value='" . $product['id'] . "' />";
    $output .= "<input type='hidden' name='submit_action' value='edit' />";
    $output .= "<br /><input type=\"button\" class='edit_button' style='padding:6px; background-color:#84DF88;' name='sendit' value='Сохранить изменения' onclick=\"checkthefieldsEditForm();\"/>";
    if ($product['approved'] != '1' && isset($current_user->wp_capabilities['editor']) && $current_user->wp_capabilities['editor'] == 1) {
        $output .= "<br /><br /><br /><br /><a class='button' href='admin.php?page=wp-shopping-cart/display-items.php&deleteid=" . $product['id'] . "' onclick=\"return conf();\" ><img src='" . SITEURL . "/img/trash.gif'> стереть изображение!</a>";
    }
    if ($product['approved'] == '1' && isset($current_user->wp_capabilities['administrator']) && $current_user->wp_capabilities['administrator'] == 1) {
        $output .= "<br /><br /><br /><br /><a class='button' href='admin.php?page=wp-shopping-cart/display-items.php&deleteid=" . $product['id'] . "' onclick=\"return conf();\" ><img src='" . SITEURL . "/img/trash.gif'> стереть изображение</a>";
    }
    $output .= "</td>\n\r";
    $output .= "</tr>\n\r";
    $output .= "</table>\n\r";
    // TODO: Remove before upload to the server! temp! local debug only!
    if ($_SERVER['SERVER_NAME'] == 'localhost') {
        $output = Utf8ToWin($output);
    }
    return $output;
}
Пример #2
0
echo "        <div id='formcontent'>\n\r";
echo "        </div>\n\r";
echo "</form>";
echo "        </div>";
?>

    <div id='additem'>
        <form  id='editproductform' method='POST' enctype='multipart/form-data'>
            <table class='additem'>
                <tr>
                    <td class="r">
                        Artist:
                    </td>
                    <td>
                        <?php 
echo brandslist();
?>
 <!-- <input id='approved' type="checkbox" name="approved"> Утверждено. -->
                    </td>
                </tr>
                <tr class='tdfirstcol'>
                    <td class='r'>
                        Select the file on your local drive:
                    </td>
                    <td>
                        <input id='fileupload' type='file' name='file' value='' />
                    </td>
                </tr>
                <tr>
                    <td class='r'>
                        Title: