Esempio n. 1
0
            } else {
                myshop_utils::redirect(_AM_MYSHOP_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
            }
        } else {
            myshop_utils::redirect(_AM_MYSHOP_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
        }
        break;
    case 'export':
        xoops_cp_header();
        myshop_adminMenu(6);
        myshop_utils::htitle(_MI_MYSHOP_ADMENU5, 4);
        $orderType = intval($_POST['cmdtype']);
        $exportFilter = $_POST['exportfilter'];
        $exportFilename = MYSHOP_PATH . 'admin/exports/' . $exportFilter . '.php';
        if (file_exists($exportFilename)) {
            require_once MYSHOP_PATH . 'admin/exports/export.php';
            require_once $exportFilename;
            $className = 'myshop_' . $exportFilter . '_export';
            if (class_exists($className)) {
                $export = new $className();
                $export->setOrderType($orderType);
                $result = $export->export();
                if ($result === true) {
                    echo "<a href='" . $export->getDownloadUrl() . "'>" . _AM_MYSHOP_EXPORT_READY . '</a>';
                }
            }
        } else {
            myshop_utils::redirect(_AM_MYSHOP_ERROR_11);
        }
        break;
}
Esempio n. 2
0
    }
}
// Vérification de la validité de la facture (si pas admin)
if (!myshop_utils::isAdmin()) {
    if ($order->getVar('cmd_state') != MYSHOP_STATE_VALIDATED) {
        // Commande non validée
        myshop_utils::redirect(_MYSHOP_ERROR12, 'index.php', 6);
    }
}
$caddy = $tmp = $products = $vats = $manufacturers = $tmp2 = $manufacturers = $productsManufacturers = array();
// Récupération des TVA
$vats = $h_myshop_vat->getAllVats();
// Récupération des caddy associés
$caddy = $h_myshop_caddy->getCaddyFromCommand($cmdId);
if (count($caddy) == 0) {
    myshop_utils::redirect(_MYSHOP_ERROR11, 'index.php', 6);
}
foreach ($caddy as $item) {
    $tmp[] = $item->getVar('caddy_product_id');
}
// Recherche des produits ***********************************************************************************************
$products = $h_myshop_products->getProductsFromIDs($tmp, true);
// Recherche des fabricants **********************************************************************************************
$tmp2 = $h_myshop_productsmanu->getFromProductsIds($tmp);
$tmp = array();
foreach ($tmp2 as $item) {
    $tmp[] = $item->getVar('pm_manu_id');
    $productsManufacturers[$item->getVar('pm_product_id')][] = $item;
}
$manufacturers = $h_myshop_manufacturer->getManufacturersFromIds($tmp);
// Informations sur la commande ***************************************************************************************
Esempio n. 3
0
        }
        $res = $h_myshop_files->insert($item);
        if ($res) {
            myshop_utils::updateCache();
            myshop_utils::redirect(_AM_MYSHOP_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
        } else {
            myshop_utils::redirect(_AM_MYSHOP_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
        }
        break;
    case 'delete':
        xoops_cp_header();
        $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
        if (empty($id)) {
            myshop_utils::redirect(_AM_MYSHOP_ERROR_1, $baseurl, 5);
        }
        $opRedirect = 'files';
        $item = null;
        $item = $h_myshop_files->get($id);
        if (is_object($item)) {
            $res = $h_myshop_files->deleteAttachedFile($item);
            if ($res) {
                myshop_utils::updateCache();
                myshop_utils::redirect(_AM_MYSHOP_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
            } else {
                myshop_utils::redirect(_AM_MYSHOP_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
            }
        } else {
            myshop_utils::redirect(_AM_MYSHOP_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
        }
        break;
}
Esempio n. 4
0
    mkdir(MYSHOP_CACHE_PATH, 0777);
    file_put_contents(MYSHOP_CACHE_PATH . '/index.html', '<script>history.go(-1);</script>');
}
$destname = '';
define("MYSHOP_ADMIN", true);
$controler = MYSHOP_ADMIN_PATH . 'actions/' . $op . '.php';
if (file_exists($controler)) {
    require $controler;
}
// Main
switch ($op) {
    case 'maintain':
        xoops_cp_header();
        myshop_adminMenu();
        require_once '../xoops_version.php';
        $tables = array();
        foreach ($modversion['tables'] as $table) {
            $tables[] = $xoopsDB->prefix($table);
        }
        if (count($tables) > 0) {
            $list = implode(',', $tables);
            $xoopsDB->queryF('CHECK TABLE ' . $list);
            $xoopsDB->queryF('ANALYZE TABLE ' . $list);
            $xoopsDB->queryF('OPTIMIZE TABLE ' . $list);
        }
        myshop_utils::updateCache();
        $h_myshop_products->forceCacheClean();
        myshop_utils::redirect(_AM_MYSHOP_SAVE_OK, $baseurl, 2);
        break;
}
xoops_cp_footer();
Esempio n. 5
0
        }
        $msg = sprintf(_AM_MYSHOP_CONF_DEL_CATEG, $category->getVar('cat_title'));
        xoops_confirm(array('op' => 'categories', 'action' => 'confdelete', 'id' => $id), 'index.php', $msg);
        break;
    case 'confdelete':
        xoops_cp_header();
        $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
        if (empty($id)) {
            myshop_utils::redirect(_AM_MYSHOP_ERROR_1, $baseurl, 5);
        }
        $opRedirect = 'categories';
        $cnt = $h_myshop_cat->getCategoryProductsCount($id);
        if ($cnt == 0) {
            $item = null;
            $item = $h_myshop_cat->get($id);
            if (is_object($item)) {
                $res = $h_myshop_cat->deleteCategory($item);
                if ($res) {
                    myshop_utils::updateCache();
                    myshop_utils::redirect(_AM_MYSHOP_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
                } else {
                    myshop_utils::redirect(_AM_MYSHOP_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
                }
            } else {
                myshop_utils::redirect(_AM_MYSHOP_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
            }
        } else {
            myshop_utils::redirect(_AM_MYSHOP_ERROR_4, $baseurl . '?op=' . $opRedirect, 5);
        }
        break;
}
Esempio n. 6
0
/**
 * Categories
 * Pattern :
 * if parent category or no category,
 * display 4 blocks, otherwise display products of category
 */
require 'header.php';
$cat_cid = isset($_GET['cat_cid']) ? intval($_GET['cat_cid']) : 0;
$GLOBALS['current_category'] = $cat_cid;
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
$category = null;
if ($cat_cid > 0) {
    $category = $h_myshop_cat->get($cat_cid);
    if (!is_object($category)) {
        myshop_utils::redirect(_MYSHOP_ERROR8, 'index.php', 5);
    }
}
// Display blocks
$xoopsOption['template_main'] = 'myshop_category.html';
require_once XOOPS_ROOT_PATH . '/header.php';
$vatArray = $tbl_categories = array();
$limit = myshop_utils::getModuleOption('perpage');
// VAT
$vatArray = $h_myshop_vat->getAllVats();
// Ccategories
$categories = $h_myshop_cat->getAllCategories();
// Template options
$xoopsTpl->assign('mod_pref', $mod_pref);
require_once MYSHOP_PATH . 'class/tree.php';
$tbl_tmp = array();
Esempio n. 7
0
            echo "<tr>\n";
        }
        $class = $class == 'even' ? 'odd' : 'even';
        if (count($names) > 0) {
            echo "<tr class='{$class}'><td colspan='3' align='center'>&nbsp;</td><td align='center'><input type='hidden' name='names' id='names' value='" . implode('|', $names) . "' /><input type='submit' name='btngo' id='btngo' value='" . _AM_MYSHOP_UPDATE_QUANTITIES . "' /></td></tr>";
        }
        echo '</table></form>';
        if (isset($pagenav) && is_object($pagenav)) {
            echo "<div align='right'>" . $pagenav->renderNav() . '</div>';
        }
        break;
    case 'updatequantities':
        $names = array();
        if (isset($_POST['names'])) {
            $names = explode('|', $_POST['names']);
            foreach ($names as $item) {
                $name = 'qty_' . $item;
                if (isset($_POST[$name]) && xoops_trim($_POST[$name]) != '') {
                    $quantity = intval($_POST[$name]);
                    $product_id = intval($item);
                    $product = null;
                    $product = $h_myshop_products->get($product_id);
                    if (is_object($product)) {
                        $h_myshop_products->updateAll('product_stock', $quantity, new Criteria('product_id', $product_id, '='), true);
                    }
                }
            }
        }
        myshop_utils::redirect(_AM_MYSHOP_SAVE_OK, $baseurl . '?op=lowstock', 2);
        break;
}
Esempio n. 8
0
 $removeBr = $removeHtml = false;
 $removeBr = isset($_POST['removebr']) ? intval($_POST['removebr']) : 0;
 $removeHtml = isset($_POST['removehtml']) ? intval($_POST['removehtml']) : 0;
 $header = isset($_POST['header']) ? $_POST['header'] : '';
 $footer = isset($_POST['footer']) ? $_POST['footer'] : '';
 $date1 = strtotime($_POST['date1']);
 $date2 = strtotime($_POST['date2']);
 $cat_id = intval($_POST['cat_cid']);
 $products = $categories = array();
 $products = $h_myshop_products->getProductsForNewsletter($date1, $date2, $cat_id);
 $newsfile = MYSHOP_NEWSLETTER_PATH;
 $categories = $h_myshop_cat->getAllCategories(0, 0, 'cat_title', 'ASC', true);
 $vats = $h_myshop_vat->getAllVats();
 $fp = fopen($newsfile, 'w');
 if (!$fp) {
     myshop_utils::redirect(_AM_MYSHOP_ERROR_7, $baseurl . '?op=newsletter', 5);
 }
 if (xoops_trim($header) != '') {
     fwrite($fp, $header);
 }
 foreach ($products as $item) {
     $content = $newsletterTemplate;
     $tblTmp = $tblTmp2 = array();
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('pm_product_id', $item->getVar('product_id'), '='));
     $tblTmp = $h_myshop_productsmanu->getObjects($criteria);
     foreach ($tblTmp as $productManufacturer) {
         $tblTmp2[] = $productManufacturer->getVar('pm_manu_id');
     }
     $manufacturers = $h_myshop_manufacturer->getObjects(new Criteria('manu_id', '(' . implode(',', $tblTmp2) . ')', 'IN'), true);
     $tblTmp = array();
Esempio n. 9
0
        $rating = intval($_POST['rating']);
        if ($rating < 1 || $rating > 10) {
            exit(_ERRORS);
        }
        $result = $h_myshop_votedata->createRating($product->getVar('product_id'), $ratinguser, $rating);
        $totalVotes = 0;
        $sumRating = 0;
        $ret = 0;
        $ret = $h_myshop_votedata->getCountRecordSumRating($product->getVar('product_id'), $totalVotes, $sumRating);
        $finalrating = $sumRating / $totalVotes;
        $finalrating = number_format($finalrating, 4);
        $h_myshop_products->updateRating($product_id, $finalrating, $totalVotes);
        $ratemessage = _MYSHOP_VOTEAPPRE . '<br />' . sprintf(_MYSHOP_THANKYOU, $xoopsConfig['sitename']);
        myshop_utils::redirect($ratemessage, MYSHOP_URL . 'product.php?product_id=' . $product->getVar('product_id'), 2);
    } else {
        myshop_utils::redirect(_MYSHOP_VOTEONCE, MYSHOP_URL . 'product.php?product_id=' . $product->getVar('product_id'), 5);
    }
} else {
    // Display form
    $GLOBALS['current_category'] = $product->getVar('product_cid');
    $xoopsOption['template_main'] = 'myshop_rate_product.html';
    require_once XOOPS_ROOT_PATH . '/header.php';
    $xoopsTpl->assign('mod_pref', $mod_pref);
    $xoopsTpl->assign('product', $product->toArray());
    $xoopsTpl->assign('global_advert', myshop_utils::getModuleOption('advertisement'));
    $breadcrumb = array($product->getLink() => $product->getVar('product_title'), MYSHOP_URL . basename(__FILE__) => _MYSHOP_RATETHISPRODUCT);
    $xoopsTpl->assign('breadcrumb', myshop_utils::breadcrumb($breadcrumb));
    $title = _MYSHOP_RATETHISPRODUCT . ' : ' . strip_tags($product->getVar('product_title')) . ' - ' . myshop_utils::getModuleName();
    myshop_utils::setMetas($title, $title);
    myshop_utils::setCSS();
}
Esempio n. 10
0
 $paypal = new myshop_paypal(myshop_utils::getModuleOption('paypal_test'), myshop_utils::getModuleOption('paypal_email'), myshop_utils::getModuleOption('paypal_money'), true, $passwordCancel);
 $commande = $h_myshop_commands->create(true);
 $commande->setVars($_POST);
 $commande->setVar('cmd_uid', $uid);
 $commande->setVar('cmd_date', date("Y-m-d"));
 $commande->setVar('cmd_state', MYSHOP_STATE_NOINFORMATION);
 $commande->setVar('cmd_ip', myshop_utils::IP());
 $commande->setVar('cmd_articles_count', count($cartForTemplate));
 $commande->setVar('cmd_total', $commandAmountTTC);
 $commande->setVar('cmd_shipping', $shippingAmount);
 $commande->setVar('cmd_password', $password);
 $commande->setVar('cmd_cancel', $passwordCancel);
 $commande->setVar('cmd_text', implode("\n", $discountsDescription));
 $res = $h_myshop_commands->insert($commande, true);
 if (!$res) {
     myshop_utils::redirect(_MYSHOP_ERROR10, MYSHOP_URL, 6);
 }
 // Save Cart
 $msgCommande = '';
 foreach ($cartForTemplate as $line) {
     $panier = $h_myshop_caddy->create(true);
     $panier->setVar('caddy_product_id', $line['product_id']);
     $panier->setVar('caddy_qte', $line['product_qty']);
     $panier->setVar('caddy_price', $line['totalPrice']);
     // Attention! All-fee price with shipping
     $panier->setVar('caddy_cmd_id', $commande->getVar('cmd_id'));
     $panier->setVar('caddy_shipping', $line['discountedShipping']);
     $panier->setVar('caddy_pass', md5(xoops_makepass()));
     // Download
     $msgCommande .= str_pad(wordwrap($line['product_title'], 60), 60, ' ') . ' ' . str_pad($line['product_qty'], 8, ' ', STR_PAD_LEFT) . ' ' . str_pad($line['totalPrice'], 10, ' ', STR_PAD_LEFT) . ' ' . str_pad($line['discountedShipping'], 10, ' ', STR_PAD_LEFT) . "\n";
     $res = $h_myshop_caddy->insert($panier, true);
Esempio n. 11
0
            myshop_utils::redirect(_MYSHOP_ERROR9, 'index.php', 4);
        }
        $product = null;
        $product = $h_myshop_products->get($productId);
        if (!is_object($product)) {
            myshop_utils::redirect(_MYSHOP_ERROR9, 'index.php', 4);
        }
        if ($product->getVar('product_online') == 0) {
            myshop_utils::redirect(_MYSHOP_ERROR2, 'index.php', 4);
        }
        if ($product->getVar('product_stock') - 1 >= 0) {
            $h_myshop_caddy->addProduct($productId, 1);
            $url = MYSHOP_URL . 'caddy.php';
            header("Location: {$url}");
        } else {
            myshop_utils::redirect(_MYSHOP_PROBLEM_QTY, 'index.php', 5);
            // No more stock
        }
        listCart();
        break;
    case 'empty':
        // Delete Caddy Content
        $h_myshop_caddy->emptyCart();
        listCart();
        break;
    case 'default':
        listCart();
        break;
}
myshop_utils::setCSS();
if (file_exists(MYSHOP_PATH . 'language/' . $xoopsConfig['language'] . '/modinfo.php')) {
Esempio n. 12
0
$caddy = $h_myshop_caddy->getCaddyFromPassword($download_id);
if (!is_object($caddy)) {
    myshop_utils::redirect(_MYSHOP_ERROR14, MYSHOP_URL, 5);
}
// Search related product
$product = null;
$product = $h_myshop_products->get($caddy->getVar('caddy_product_id'));
if ($product == null) {
    myshop_utils::redirect(_MYSHOP_ERROR15, MYSHOP_URL, 5);
}
// Verifiy order paiment
$order = null;
$order = $h_myshop_commands->get($caddy->getVar('caddy_cmd_id'));
if ($order == null) {
    myshop_utils::redirect(_MYSHOP_ERROR16, MYSHOP_URL, 5);
}
// Send file to download if it exists
$file = '';
$file = $product->getVar('product_download_url');
if (xoops_trim($file) == '') {
    myshop_utils::redirect(_MYSHOP_ERROR17, MYSHOP_URL, 5);
}
if (!file_exists($file)) {
    myshop_utils::redirect(_MYSHOP_ERROR18, MYSHOP_URL, 5);
}
// Update, file is not available to download
$h_myshop_caddy->markCaddyAsNotDownloadableAnyMore($caddy);
// Display file with mime type
header("Content-Type: " . myshop_utils::getMimeType($file));
header('Content-disposition: inline; filename="' . basename($file) . '"');
readfile($file);