Example #1
0
 /**
  * Supprime un produit (et tout ce qui lui est relatif)
  * @param oledrion_products $product
  */
 function deleteProduct(oledrion_products $product)
 {
     global $xoopsModule;
     $id = $product->getVar('product_id');
     // On commence par supprimer les commentaires
     $mid = $xoopsModule->getVar('mid');
     xoops_comment_delete($mid, $id);
     // Puis les votes
     $this->handlers->h_oledrion_votedata->deleteProductRatings($id);
     // Puis les produits relatifs
     $this->handlers->h_oledrion_related->deleteProductRelatedProducts($id);
     // Les images (la grande et la miniature)
     $product->deletePictures();
     // Le fichier attaché
     $product->deleteAttachment();
     // Les fichiers attachés
     $this->handlers->h_oledrion_files->deleteProductFiles($id);
     // Suppression dans les paniers persistants enregistrés
     $this->handlers->h_oledrion_persistent_cart->deleteProductForAllCarts($id);
     // Les attributs qui lui sont rattachés
     $this->handlers->h_oledrion_attributes->deleteProductAttributes($id);
     // Le produit dans les listes
     $this->handlers->h_oledrion_products_list->deleteProductFromLists($id);
     // La relation entre le produit et le fabricant
     $this->handlers->h_oledrion_productsmanu->removeManufacturerProduct($id);
     // Le produit dans les remises
     $this->handlers->h_oledrion_discounts->removeProductFromDiscounts($id);
     // Et le produit en lui même, à la fin
     return $this->handlers->h_oledrion_products->delete($product, true);
 }
 /**
  * Retourne le nom des champs (représentant les attributs) obligatoires que l'on devrait trouver suite à une sélection de produit
  *
  * @param oledrion_products $product
  * @return array	objets des type oledrion_attributes
  */
 function getProductMandatoryFieldsList(oledrion_products $product)
 {
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('attribute_product_id', $product->getVar('attribute_product_id'), '='));
     $criteria->add(new Criteria('attribute_mandatory', 1, '='));
     return $this->getObjects($criteria);
 }
Example #3
0
 if (isset($_POST['product_vendors'])) {
     $vendor = intval($_POST['product_vendors']);
     if ($vendor > 0) {
         $sql .= ' AND (product_vendor_id = ' . $vendor . ')';
     }
 }
 // Recherche sur du texte
 if (isset($_POST['product_text']) && xoops_trim($_POST['product_text']) != '') {
     $temp_queries = $queries = array();
     $temp_queries = preg_split('/[\\s,]+/', $_POST['product_text']);
     foreach ($temp_queries as $q) {
         $q = trim($q);
         $queries[] = $myts->addSlashes($q);
     }
     if (count($queries) > 0) {
         $tmpObject = new oledrion_products();
         $datas = $tmpObject->getVars();
         $fields = array();
         $cnt = 0;
         foreach ($datas as $key => $value) {
             if ($value['data_type'] == XOBJ_DTYPE_TXTBOX || $value['data_type'] == XOBJ_DTYPE_TXTAREA) {
                 if ($cnt == 0) {
                     $fields[] = 'b.' . $key;
                 } else {
                     $fields[] = ' OR b.' . $key;
                 }
                 $cnt++;
             }
         }
         $count = count($queries);
         $cnt = 0;
 /**
  * Recherche des attributs associés à chaque produit
  *
  * @param oledrion_products $product
  * @param attray $attributes
  * @since 2.3
  */
 private function addAssociatedAttributes(oledrion_products $product, $attributes)
 {
     if (!isset($this->associatedAttributesPerProduct[$product->product_id])) {
         $this->associatedAttributesPerProduct[$product->product_id] = $product->getProductsAttributesList($attributes);
     }
 }
Example #5
0
 /**
  * Clone d'un produit
  *
  * @param  object $originalProduct Le produit à cloner
  * @return mixed  Soit l'objet représentant le nouveau produit soit false
  */
 public function cloneProduct(oledrion_products $originalProduct)
 {
     global $h_oledrion_productsmanu, $h_oledrion_files, $h_oledrion_productsmanu, $h_oledrion_related, $oledrion_handlers;
     $newProduct = $originalProduct->xoopsClone();
     if (OLEDRION_DUPLICATED_PLACE == 'right') {
         $newProduct->setVar('product_title', $originalProduct->getvar('product_title') . ' ' . _AM_OLEDRION_DUPLICATED);
     } else {
         $newProduct->setVar('product_title', _AM_OLEDRION_DUPLICATED . ' ' . $originalProduct->getvar('product_title'));
     }
     $newProduct->setVar('product_id', 0);
     $newProduct->setNew();
     // Copie des 2 images
     if (xoops_trim($originalProduct->getVar('product_image_url')) != '') {
         $resCopy = oledrion_utils::duplicateFile(OLEDRION_PICTURES_PATH, $originalProduct->getVar('product_image_url'));
         if ($resCopy !== false) {
             $newProduct->setVar('product_image_url', $resCopy);
         }
     }
     if (xoops_trim($originalProduct->getVar('product_thumb_url')) != '') {
         $resCopy = oledrion_utils::duplicateFile(OLEDRION_PICTURES_PATH, $originalProduct->getVar('product_thumb_url'));
         if ($resCopy !== false) {
             $newProduct->setVar('product_thumb_url', $resCopy);
         }
     }
     // Copie du fichier attaché
     if (xoops_trim($originalProduct->getVar('product_attachment')) != '') {
         $resCopy = oledrion_utils::duplicateFile(OLEDRION_ATTACHED_FILES_PATH, $originalProduct->getVar('product_attachment'));
         if ($resCopy !== false) {
             $newProduct->setVar('product_attachment', $resCopy);
         }
     }
     $res = $this->insert($newProduct, true);
     if ($res) {
         $newProductId = $newProduct->getVar('product_id');
         // Copie des fichiers liés
         if ($h_oledrion_files->getProductFilesCount($originalProduct->product_id) > 0) {
             $attachedFiles = array();
             $attachedFiles = $h_oledrion_files->getProductFiles($originalProduct->product_id);
             if (count($attachedFiles) > 0) {
                 foreach ($attachedFiles as $oneFile) {
                     $newAttachedFile = $oneFile->xoopsClone();
                     $newAttachedFile->setVar('file_product_id', $newProductId);
                     $resCopy = oledrion_utils::duplicateFile(OLEDRION_ATTACHED_FILES_PATH, $oneFile->getVar('file_filename'));
                     if ($resCopy !== false) {
                         $newAttachedFile->setVar('file_filename', $resCopy);
                     }
                     $newAttachedFile->setNew();
                     $h_oledrion_files->insert($newAttachedFile, true);
                 }
             }
         }
         // Copie des fabricants
         $tblTmp = array();
         $criteria = new Criteria('pm_product_id', $originalProduct->getVar('product_id'), '=');
         $tblTmp = $h_oledrion_productsmanu->getObjects($criteria);
         foreach ($tblTmp as $productAuthor) {
             $newProductAuthor = $productAuthor->xoopsClone();
             $newProductAuthor->setVar('pm_product_id', $newProductId);
             $newProductAuthor->setVar('pm_id', 0);
             $newProductAuthor->setNew();
             $h_oledrion_productsmanu->insert($newProductAuthor, true);
         }
         // Copie des produits relatifs
         $tblTmp = array();
         $criteria = new Criteria('related_product_id', $originalProduct->getVar('product_id'), '=');
         $tblTmp = $h_oledrion_related->getObjects($criteria);
         foreach ($tblTmp as $related) {
             $newRelated = $related->xoopsClone();
             $newRelated->setVar('related_product_id', $newProductId);
             $newRelated->setVar('related_id', 0);
             $newRelated->setNew();
             $h_oledrion_related->insert($newRelated, true);
         }
         // Copie des attributs
         if ($oledrion_handlers->h_oledrion_attributes->getProductAttributesCount($originalProduct->product_id) > 0) {
             $criteria = new Criteria('attribute_product_id', $originalProduct->product_id, '=');
             $tblTmp = $oledrion_handlers->h_oledrion_attributes->getObjects($criteria);
             foreach ($tblTmp as $attribute) {
                 $newAttribute = $attribute->xoopsClone();
                 $newAttribute->setVar('attribute_product_id', $newProductId);
                 $newAttribute->setVar('attribute_id', 0);
                 $newAttribute->setNew();
                 $oledrion_handlers->h_oledrion_attributes->insert($newAttribute, true);
             }
         }
         return $newProduct;
     } else {
         return false;
     }
 }
 /**
  * Retourne les informations formatées de l'attribut pour affichage dans la facture
  *
  * @param oledrion_products $product	Le produit concerné par l'attribut
  * @return array
  * @since 2.3.2009.03.23
  */
 function renderForInvoice(oledrion_products $product, $format = 's')
 {
     $names = $prices = $ret = array();
     $names = $this->getOption('ca_attribute_names', $format);
     if (oledrion_utils::getModuleOption('use_price')) {
         $prices = $this->getOption('ca_attribute_prices', $format);
     }
     $oledrion_Currency = oledrion_Currency::getInstance();
     $counter = 0;
     foreach ($names as $name) {
         $price = 0;
         if (oledrion_utils::getModuleOption('use_price')) {
             if (isset($prices[$counter])) {
                 $price = oledrion_utils::getAmountWithVat(floatval($prices[$counter]), $product->getVar('product_vat_id'));
                 $price = $oledrion_Currency->amountForDisplay($price);
             }
         }
         $ret[] = array('ca_attribute_name' => $name, 'ca_attribute_price_formated' => $price);
         $counter++;
     }
     return $ret;
 }
Example #7
0
/**
 * ****************************************************************************
 * oledrion - MODULE FOR XOOPS
 * Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         oledrion
 * @author 			Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
 *
 * Version : $Id:
 * ****************************************************************************
 */
function oledrion_search($queryarray, $andor, $limit, $offset, $userid)
{
    global $xoopsDB;
    require XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
    require_once XOOPS_ROOT_PATH . '/modules/oledrion/class/oledrion_products.php';
    // Recherche dans les produits
    $sql = 'SELECT product_id, product_title, product_submitted, product_submitter FROM ' . $xoopsDB->prefix('oledrion_products') . ' WHERE (product_online = 1';
    if (oledrion_utils::getModuleOption('show_unpublished') == 0) {
        // Ne pas afficher les produits qui ne sont pas publiés
        $sql .= ' AND product_submitted <= ' . time();
    }
    if (oledrion_utils::getModuleOption('nostock_display') == 0) {
        // Se limiter aux seuls produits encore en stock
        $sql .= ' AND product_stock > 0';
    }
    if ($userid != 0) {
        $sql .= '  AND product_submitter = ' . $userid;
    }
    $sql .= ') ';
    $tmpObject = new oledrion_products();
    $datas = $tmpObject->getVars();
    $tblFields = array();
    $cnt = 0;
    foreach ($datas as $key => $value) {
        if ($value['data_type'] == XOBJ_DTYPE_TXTBOX || $value['data_type'] == XOBJ_DTYPE_TXTAREA) {
            if ($cnt == 0) {
                $tblFields[] = $key;
            } else {
                $tblFields[] = ' OR ' . $key;
            }
            $cnt++;
        }
    }
    $count = count($queryarray);
    $more = '';
    if (is_array($queryarray) && $count > 0) {
        $cnt = 0;
        $sql .= ' AND (';
        $more = ')';
        foreach ($queryarray as $oneQuery) {
            $sql .= '(';
            $cond = " LIKE '%" . $oneQuery . "%' ";
            $sql .= implode($cond, $tblFields) . $cond . ')';
            $cnt++;
            if ($cnt != $count) {
                $sql .= ' ' . $andor . ' ';
            }
        }
    }
    $sql .= $more . ' ORDER BY product_submitted DESC';
    $i = 0;
    $ret = array();
    $myts =& MyTextSanitizer::getInstance();
    $result = $xoopsDB->query($sql, $limit, $offset);
    while ($myrow = $xoopsDB->fetchArray($result)) {
        $ret[$i]['image'] = 'images/product.png';
        $ret[$i]['link'] = "product.php?product_id=" . $myrow['product_id'];
        $ret[$i]['title'] = $myts->htmlSpecialChars($myrow['product_title']);
        $ret[$i]['time'] = $myrow['product_submitted'];
        $ret[$i]['uid'] = $myrow['product_submitter'];
        $i++;
    }
    return $ret;
}