function tc_shopping_cart_detail($atts) { session_start(); extract(lAtts(array('checkout_section' => 'checkout'), $atts)); $cart = $_SESSION['cart']; if (empty($cart)) { $cart = new bckCart(); } if (isset($_REQUEST['empty_cart'])) { $cart->empty_cart(); $_SESSION['cart'] = $cart; } $cartHTML = startTable("shopping_cart") . tr(n . hCell("Item") . n . hCell("Quantity") . n . hCell("Price") . n . hCell("Subtotal")); foreach ($cart->items as $product) { $image = '<img src="' . product_image_display($product['image'], "small") . '" alt="Product Detail" class="thumb"/>'; $link = "<a href='" . permlinkurl_id($product['ID']) . "' title='View product detail'>" . $product['name'] . "</a>"; $cartHTML .= tr(n . td($image . $link) . n . td($product['qty']) . n . td(_tc_price_format($product['price'])) . n . td(_tc_price_format($product['price']))); } $cartHTML .= endTable(); $cartHTML .= tag(tag(tag("Empty Cart", "a", " href='?empty_cart=true' class='cartAction' id='emptyCart'"), "li") . tag(tag("Continue Shopping", "a", " href='#' class='cartAction' id='continueShopping'"), "li") . tag(tag("Checkout", "a", " href='/{$checkout_section}/' class='cartAction' id='checkout'"), "li") . tag(tag(_tc_price_format($cart->total), "span", " class='cartTotal'"), "li"), "ul"); return $cartHTML; }
function product_save() { global $txp_user, $vars, $txpcfg, $prefs; extract($prefs); $incoming = psa($vars); define("IMPATH", $path_to_site . '/' . $img_dir . '/'); $oldArticle = safe_row('Status, url_title, Title, Image, custom_6, custom_7, custom_8', 'textpattern', 'ID = ' . (int) $incoming['ID']); if (!($oldArticle['Status'] >= 4 and has_privs('article.edit.published') or $oldArticle['Status'] >= 4 and $incoming['AuthorID'] == $txp_user and has_privs('article.edit.own.published') or $oldArticle['Status'] < 4 and has_privs('article.edit') or $oldArticle['Status'] < 4 and $incoming['AuthorID'] == $txp_user and has_privs('article.edit.own'))) { // Not allowed, you silly rabbit, you shouldn't even be here. // Show default editing screen. product_edit(); return; } $wrapper = new TXP_Wrapper(); $incoming = $wrapper->textile_main_fields($incoming, $use_textile); extract(doSlash($incoming)); extract(array_map('assert_int', psa(array('ID', 'Status', 'textile_body', 'textile_excerpt')))); $Annotate = ps('Annotate') ? assert_int(ps('Annotate')) : 0; if (!has_privs('article.publish') && $Status >= 4) { $Status = 3; } if ($reset_time) { $whenposted = "Posted=now()"; } else { $when = strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second) - tz_offset(); $when = "from_unixtime({$when})"; $whenposted = "Posted={$when}"; } if (isset($new_vendor_name) && !empty($new_vendor_name)) { $custom_5 = $new_vendor_name; cat_vendor_category_create($custom_5); } else { if (isset($vendor)) { $custom_5 = $vendor; } } //Auto-Update custom-titles according to Title, as long as unpublished and NOT customized if (empty($url_title) || $oldArticle['Status'] < 4 && $oldArticle['url_title'] == $url_title && $oldArticle['url_title'] == stripSpace($oldArticle['Title'], 1) && $oldArticle['Title'] != $Title) { $url_title = stripSpace($Title_plain, 1); } if (!$Annotate) { $Annotate = 0; } //IMAGE DELETE/UPDATE FUNCTIONALITY //======================================= if (strtolower($Image) == "delete") { $delPath = str_replace("http://" . $siteurl . "/images/", IMPATH, $oldArticle['Image']); unlink($delPath); unlink(product_image_display($delPath, "small")); unlink(product_image_display(str_replace("gif", "jpg", $delPath), "large")); $Image = ""; } if (strtolower($custom_6) == "delete") { $delPath = str_replace("http://" . $siteurl . "/images/", IMPATH, $oldArticle['custom_6']); unlink($delPath); unlink(product_image_display($delPath, "small")); unlink(product_image_display(str_replace("gif", "jpg", $delPath), "large")); $custom_6 = ""; } if (strtolower($custom_7) == "delete") { $delPath = str_replace("http://" . $siteurl . "/images/", IMPATH, $oldArticle['custom_7']); unlink($delPath); unlink(product_image_display($delPath, "small")); unlink(product_image_display(str_replace("gif", "jpg", $delPath), "large")); $custom_7 = ""; } if (strtolower($custom_8) == "delete") { $delPath = str_replace("http://" . $siteurl . "/images/", IMPATH, $oldArticle['custom_8']); unlink($delPath) or die("can't delete file: " . $delPath); unlink(product_image_display($delPath, "small")); unlink(product_image_display(str_replace("gif", "jpg", $delPath), "large")); $custom_8 = ""; } //UPDATE ARTICLE //======================================= safe_update("textpattern", "Title = '{$Title}',\n\t\t\tBody = '{$Body}',\n\t\t\tBody_html = '{$Body_html}',\n\t\t\tExcerpt = '{$Excerpt}',\n\t\t\tExcerpt_html = '{$Excerpt_html}',\n\t\t\tKeywords = '{$Keywords}',\n\t\t\tImage = '{$Image}',\n\t\t\tStatus = {$Status},\n\t\t\tLastMod = now(),\n\t\t\tLastModID = '{$txp_user}',\n\t\t\tSection = '{$Section}',\n\t\t\tCategory1 = '{$Category1}',\n\t\t\tCategory2 = '{$Category2}',\n\t\t\tAnnotate = {$Annotate},\n\t\t\ttextile_body = {$textile_body},\n\t\t\ttextile_excerpt = {$textile_excerpt},\n\t\t\toverride_form = '{$override_form}',\n\t\t\turl_title = '{$url_title}',\n\t\t\tAnnotateInvite = '{$AnnotateInvite}',\n\t\t\tcustom_1 = '{$custom_1}',\n\t\t\tcustom_2 = '{$custom_2}',\n\t\t\tcustom_3 = '{$custom_3}',\n\t\t\tcustom_4 = '{$custom_4}',\n\t\t\tcustom_5 = '{$custom_5}',\n\t\t\tcustom_6 = '{$custom_6}',\n\t\t\tcustom_7 = '{$custom_7}',\n\t\t\tcustom_8 = '{$custom_8}',\n\t\t\tcustom_9 = '{$custom_9}',\n\t\t\tcustom_10 = '{$custom_10}',\n\t\t\t{$whenposted}", "ID = {$ID}"); save_custom_fields($_REQUEST['custom_fields'], $ID); //IMAGE UPLOAD //======================= if ($_FILES['uploadFile']['error'] == "0") { $file = $_FILES['uploadFile']; } else { if ($_FILES['uploadFile1']['error'] == "0") { $file = $_FILES['uploadFile1']; } else { if ($_FILES['uploadFile2']['error'] == "0") { $file = $_FILES['uploadFile2']; } else { if ($_FILES['uploadFile3']['error'] == "0") { $file = $_FILES['uploadFile3']; } else { if ($_FILES['uploadFile4']['error'] == "0") { $file = $_FILES['uploadFile4']; } } } } } if ($file["type"] == "image/gif" || $file["type"] == "image/jpeg" || $file["type"] == "image/png") { // prepare the image for insertion //we need to check what images have been uploaded already $article_updated = safe_row("Image, custom_6, custom_7, custom_8", "textpattern", "ID = {$ID}"); extract($article_updated); if (empty($Image)) { $image_num = ""; } else { if (empty($custom_6)) { $image_num = "2"; } else { if (empty($custom_7)) { $image_num = "3"; } else { if (empty($custom_8)) { $image_num = "4"; } } } } echo "Uploading image: " . $file['name']; $img = $file['tmp_name']; upload_image($img, $image_num, $ID); //echo "here"; die(); } //END IMAGE UPLOAD //======================= if ($Status >= 4) { if ($oldArticle['Status'] < 4) { if (!function_exists("do_pings")) { require_once txpath . '/include/txp_article.php'; do_pings(); } } update_lastmod(); } product_edit("", "", "Product Saved"); }
function product_edit($event, $step, $message = '') { global $vars, $txp_user, $comments_disabled_after, $txpcfg, $prefs, $general_settings; extract($prefs); define("IMPATH", $path_to_site . '/' . $img_dir . '/'); extract(gpsa(array('view', 'from_view', 'step'))); if (!empty($GLOBALS['ID'])) { // newly-saved article $ID = $GLOBALS['ID']; $step = 'edit'; } else { $ID = gps('ID'); } //GET ARTICLE DATA FOR 'EDIT' & 'SAVE' STEP //================================== if ($step == "edit" || $step == "save" && !empty($ID)) { $pull = true; //-- it's an existing article - off we go to the db $ID = assert_int($ID); $rs = safe_row("*, unix_timestamp(Posted) as sPosted,\r\n\t\t\t\tunix_timestamp(LastMod) as sLastMod", "textpattern", "ID={$ID}"); extract($rs); if ($AnnotateInvite != $comments_default_invite) { $AnnotateInvite = $AnnotateInvite; } else { $AnnotateInvite = $comments_default_invite; } $custom_fields = safe_rows("*", "product_custom_fields", "articleID = {$ID} ORDER BY id DESC"); $step = "save"; } else { if (empty($step)) { $step = "create"; } } $textile = new Textile(); $textile_body = $use_textile; $textile_excerpt = $use_textile; $page_title = "Add a new product"; $message = ""; pagetop($page_title, $message); if (count($custom_fields) > 0) { $startFieldNum = $custom_fields[0]['id'] + 1; } else { $startFieldNum = 0; } echo "<script type='text/javascript'>var fieldNum = {$startFieldNum}</script>"; //JS INCLUDES //================================== //print_r($prefs); echo '<script type="text/javascript" src="http://' . $siteurl . '/jquery.js"></script>'; echo '<script type="text/javascript" src="http://' . $siteurl . '/jquery.js"></script>'; //CSS FOR PRODUCT DISPLAY //================================== echo n . '<style type="text/css">' . n . 'h4.productHeading{' . n . ' color:gray;' . n . ' margin-bottom:0px;' . n . '}' . n . 'h4.productHeading span{' . n . ' float:right;' . n . ' font-size:9px;' . n . ' font-style:italic;' . n . ' font-weight:normal;' . n . '}' . n . '.product-options-sub{' . n . ' padding: 10px;' . n . '}' . n . '.product-options-sub em{' . n . ' color:gray;' . n . '}' . n . '.product-options-sub legend{' . n . ' font-size:11px;' . n . '}' . n . '.product-options-sub label{' . n . ' font-size:11px;' . n . ' padding-bottom: 5px;' . n . '}' . n . '#images ul.plain-list li{' . n . ' float:left;' . n . ' margin-right:10px;' . n . ' margin-bottom:10px;' . n . ' width:375px;' . n . '}' . n . '#images ul.plain-list li img{' . n . ' border-width: 1px;' . n . ' border-color:#BBBBBB;' . n . ' border-style:solid;' . n . ' padding:3px;' . n . ' background-color: #E0E0E0;' . n . ' float:left;' . n . '}' . n . '#images ul.plain-list li .imageEdit{' . n . ' background-color:#E0E0E0;' . n . ' height: 15px;' . n . ' width: 250px;' . n . ' text-align:left;' . n . ' padding:3px 3px 3px 110px;' . n . ' margin-top:0px;' . n . '}' . n . '#images ul.plain-list li .imageUpload{' . n . ' margin-top: 5px;' . n . ' padding:3px;' . n . ' width: 275px;' . n . ' border-width: 1px;' . n . ' border-color:#E0E0E0;' . n . ' border-style:solid;' . n . '}' . n . '</style>'; doJS(); echo n . n . '<form name="product" method="post" action="index.php" enctype="multipart/form-data">'; echo '<input type="hidden" name="textile_body" value="1"/>'; echo '<input type="hidden" name="textile_excerpt" value="1"/>'; echo '<input type="hidden" name="Section" value="store"/>'; echo hInput('ID', $ID) . eInput('product') . sInput($step) . '<input type="hidden" name="view" />' . startTable('edit') . '<tr>' . n; //if ($view == 'text') //{ //-- markup help -------------- echo '<td id="article-main">'; echo "<h4 class='productHeading'>Product name</h4>"; echo '<p><input type="text" id="title" name="Title" value="' . cleanfInput($Title) . '" class="edit" size="40" tabindex="1" />'; if (($Status == 4 or $Status == 5) and $step != 'create') { include_once txpath . '/publish/taghandlers.php'; echo sp . sp . '<a href="' . permlinkurl_id($ID) . '">' . gTxt('view') . '</a>'; } echo '</p>'; echo "<h4 class='productHeading'><span>Textile & HTML allowed</span> Describe the product</h4>"; echo n . graf('<textarea id="body" name="Body" cols="55" rows="31" tabindex="2" style="height: 180px;">' . htmlspecialchars($Body) . '</textarea>'); //PRODUCT OPTIONS //================================ //echo '<div id="productOptions" style="border-width:1px; border-color:#E1E1E1; border-style:solid; padding:5px; background-color:#F3F4F4;">'; //PRODUCT & PRICE //================================ echo n . n . '<fieldset class="product-options-sub" style="background-color:white">' . '<div style="float:left; margin-right: 40px;">' . n . graf('<label for="price">Price</label> ' . br . n . '<input style="width: 50px;" type="text" name="custom_1" id="price" value="' . cleanfInput($custom_1) . '"/> <em>' . $general_settings['store_currency'] . '</em>') . n . '</div>' . n . graf('<label for="weight">Weight</label>' . br . n . '<input type="text" style="width: 50px;" name="custom_2" id="weight" value="' . cleanfInput($custom_2) . '"/> <em>kg</em>'); echo n . "</fieldset>"; //CUSTOM FIELDS //================================ if (isset($ID)) { $custom_fields = get_custom_fields($ID); } else { $custom_fields = ''; } echo n . n . '<fieldset class="product-options-sub" style="background-color:white" id="custom_fields">' . n . '<legend>Custom Fields <span>[<a href="javascript:addCustomField(0);">Add a new custom field</a>]</span></legend>'; echo $custom_fields; echo n . "</fieldset>"; //CATEGORIES //================================ //if(!is_callable("rss_admin_catlist")){ echo n . n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Category <small>[<a href="?event=category">edit</a>]</small></legend>' . '<div style="float:left; margin-right: 10px;">' . n . '<label for="category">Select existing category </label> ' . br . n . build_list("category", "txp_category", "name", "title", $Category1, "parent='Products'", true, "ORDER BY name") . n . '</div>' . n . graf('<label for="new_category_name">Or create a new category</label>' . br . n . '<input id="new_category_name" type="text" name="new_category_name"/>'); echo n . "</fieldset>"; //} //VENDORS //================================ echo n . n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Vendor <small>[<a href="?event=category">edit</a>]</small></legend>' . '<div style="float:left; width:50%;">' . n . '<label for="vendor">Select existing vendor </label> ' . br . n . build_list("vendor", "txp_category", "name", "title", $Category2, "parent='Vendors'", true, "ORDER BY name") . n . '</div>' . n . graf('<label for="new_vendor_name">Or create a new vendor</label>' . br . n . '<input id="new_vendor_name" type="text" name="new_vendor_name"/>'); echo n . "</fieldset>"; //INVENTORY //================================ echo n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Inventory</legend>'; echo n . '<label for="sku">SKU <em>Stock keeping unit</em></label>' . n . br . '<input type="text" name="custom_3" id="sku" value="' . $custom_3 . '"/>' . br . br; if (isset($custom_4) && !empty($custom_4)) { $showLevel = true; $levelSelected = "selected = \"selected\""; $levelStyle = 'display:block;'; } else { $showLevel = false; $levelSelected = ""; $levelStyle = 'display:none;'; } echo n . '<select name="trackOptions" id="trackOptions" onchange="if(this.value == \'doTrack\'){$(\'#stockLevel\').show();}else{$(\'#stockLevel\').hide();}">' . n . n . '<option value="dontTrack">Don\'t track stock level</option>' . n . '<option value="doTrack" ' . $levelSelected . '>Keep track of stock level</option>' . n . '</select>' . br . br; echo n . '<div id="stockLevel" style="' . $levelStyle . '">' . n . '<label for="items_in_stock">Number of items in stock:</label>' . n . '<input type="text" name="custom_4" id="items_in_stock" style="width:20px;" value="' . cleanfInput($custom_4) . '"/>' . n . '</div><!--/stockLevel-->'; echo n . "</fieldset>"; //IMAGES //================================ doJS(); if ($step == "create") { echo n . '<fieldset class="product-options-sub" style="background-color:white">' . n . '<legend>Product images</legend>'; echo n . '<em>Allowed file types are JPG, GIF & PNG</em>'; echo n . '<input type="file" name="uploadFile"/>' . n; echo n . "</fieldset>"; } else { if ($step == "edit" || $step == "save" || empty($step)) { echo n . '<fieldset class="product-options-sub" id="images" style="background-color:white">' . n . '<legend>Product images</legend>'; echo n . '<ul class="plain-list" id="image_list">'; if (isset($Image) && !empty($Image)) { echo n . '<li id="image1"> <img src="' . product_image_display($Image, "small") . '" alt="Product Image"/> <div class="imageEdit" style="display:block;"> <a href="javascript:deleteImage(\'1\')">Delete Image</a> | <a href="javascript:updateImage(\'1\')">Update Image</a> <div class="imageUpload" id="imageUpload1" style="display:none;"> Browse for new image: <input type="file" name="uploadFile1"/> and <input type="submit" value="Save"/> <a href="javascript:cancelUpload(\'1\')">Cancel</a> <input type="hidden" name="updateImage1" id="updateImage1" value="0"/> </div> <input id="imageField1" type="hidden" name="Image" value="' . $Image . '"/> </div> </li>'; } if (isset($custom_6) && !empty($custom_6)) { echo n . '<li id="image2"><img src="' . product_image_display($custom_6, "small") . '" alt="Product Image"/> <div class="imageEdit" id="image1Control" style="display:block;"> <a href="javascript:deleteImage(\'2\')">Delete Image</a> | <a href="javascript:updateImage(\'2\')">Update Image</a> <div class="imageUpload" id="imageUpload2" style="display:none;"> Browse for new image: <input type="file" name="uploadFile2"/> and <input type="submit" value="Save"/> <a href="javascript:cancelUpload(\'2\')">Cancel</a> <input type="hidden" name="updateImage2" id="updateImage2" value="0"/> </div> </div><input id="imageField2" type="hidden" name="custom_6" value="' . $custom_6 . '"/></li>'; } if (isset($custom_7) && !empty($custom_7)) { echo n . '<li id="image3"><img src="' . product_image_display($custom_7, "small") . '" alt="Product Image"/> <div class="imageEdit" id="image1Control" style="display:block;"> <a href="javascript:deleteImage(\'3\')">Delete Image</a> | <a href="javascript:updateImage(\'3\')">Update Image</a> <div class="imageUpload" id="imageUpload3" style="display:none;"> Browse for new image: <input type="file" name="uploadFile3"/> and <input type="submit" value="Save"/> <a href="javascript:cancelUpload(\'3\')">Cancel</a> <input type="hidden" name="updateImage3" id="updateImage3" value="0"/> </div> </div> <input id="imageField3" type="hidden" name="custom_7" value="' . $custom_7 . '"/></li>'; } if (isset($custom_8) && !empty($custom_8)) { echo n . '<li id="image4"><img src="' . product_image_display($custom_8, "small") . '" alt="Product Image"/> <div class="imageEdit" id="image1Control" style="display:block;"> <a href="javascript:deleteImage(\'4\')">Delete Image</a> | <a href="javascript:updateImage(\'4\')">Update Image</a> <div class="imageUpload" id="imageUpload4" style="display:none;"> Browse for new image: <input type="file" name="uploadFile4"/> and <input type="submit" value="Save"/> <a href="javascript:cancelUpload(\'4\')">Cancel</a> <input type="hidden" name="updateImage4" id="updateImage4" value="0"/> </div> </div><input id="imageField4" type="hidden" name="custom_8" value="' . $custom_8 . '"/></li>'; } echo n . "</ul><br style='clear:both;'/>"; echo n . '<a href="javascript:void(0);" onclick="document.getElementById(\'otherImageUpload\').style.display = \'block\'">Add an image</a>' . n; echo n . '<div id="otherImageUpload" style="display:none; margin-top: 10px;">'; echo n . '<em>Allowed file types are JPG, GIF & PNG</em>'; echo n . '<input type="file" name="uploadFile"/> and <input type="submit" value="upload"/>' . n; echo n . '</div>'; echo n . "</fieldset>"; echo n . '<div id="data"></div>'; } } //echo '</div>'; // end productOptions // end left content area echo hInput('from_view', $view), '</td>'; echo '<td id="article-col-2" style="padding-top: 75px;">'; //start article-col-2 //PRODUCT STATUS //================================ echo n . n . '<fieldset id="write-status">' . n . '<legend>' . gTxt('status') . '</legend>' . n . status_radio_product($Status) . n . '</fieldset>'; //-- comments stuff -------------- if ($step == "create") { //Avoiding invite disappear when previewing $AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite; if ($comments_on_default == 1) { $Annotate = 1; } } if ($use_comments == 1) { echo n . n . '<fieldset id="write-comments">' . n . '<legend>Allow product reviews</legend>'; $comments_expired = false; if ($step != 'create' && $comments_disabled_after) { $lifespan = $comments_disabled_after * 86400; $time_since = time() - $sPosted; if ($time_since > $lifespan) { $comments_expired = true; } } if ($comments_expired) { echo n . n . graf(gTxt('expired')); } else { echo n . n . graf(onoffRadio('Annotate', $Annotate)) . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite')); } echo n . n . '</fieldset>'; } /*if(is_callable("rss_admin_catlist")){ echo "<fieldset id='write-sort'></fieldset>"; echo rss_admin_catlist(); }*/ //wilshireone multipule categories //-- publish button -------------- echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4); echo '</td> <!--/article-col-2-->'; //end article-col-2 echo '</td></tr></table></form>'; }