Example #1
0
 /**
  * Class constructor
  *
  * @return void
  */
 public function __construct($options)
 {
     parent::__construct($options);
     $imageSrc = $options['imageSrc'];
     $dataId = $options['dataId'];
     $imgField = $options['imgField'];
     $isNewImage = $options['isNewImage'];
     $moduleName = $options['moduleName'];
     // List of sub categories
     $oItems = new ItemsObject();
     $listItems = $oItems->itemsCollection(Zend_Registry::get('currentEditLanguage'));
     $items = new Zend_Form_Element_Select('IP_ItemId');
     $items->setLabel($this->getView()->getCibleText('form_gift_item_label'))->setAttrib('class', 'largeSelect')->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))));
     $items->addMultiOption('', $this->getView()->getCibleText('form_select_default_label'));
     $items->addMultiOptions($listItems);
     $this->addElement($items);
     // discount item price
     $price = new Zend_Form_Element_Text('IP_Price');
     $price->setLabel($this->getView()->getCibleText('form_item_specialPrice_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
     $this->addElement($price);
     // List of sub categories
     $conditionItems = new Zend_Form_Element_Select('IP_ConditionItemId');
     $conditionItems->setLabel($this->getView()->getCibleText('form_condition_item_label'))->setAttrib('class', 'largeSelect')->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))));
     $conditionItems->addMultiOption('', $this->getView()->getCibleText('form_select_default_label'));
     $conditionItems->addMultiOptions($listItems);
     $this->addElement($conditionItems);
     // number of items to add items dicount
     $nbItem = new Zend_Form_Element_Text('IP_NbItem');
     $nbItem->setLabel($this->getView()->getCibleText('form_number_items_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
     $this->addElement($nbItem);
     // number of items to add items dicount
     $conditionAmount = new Zend_Form_Element_Text('IP_ConditionAmount');
     $conditionAmount->setLabel($this->getView()->getCibleText('form_condition_amount_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'smallTextInput');
     $this->addElement($conditionAmount);
 }
Example #2
0
 /**
  * Controller action to manage the details of the cart.
  * Update/delete items or load the list.
  *
  * @return void
  */
 public function cartdetailsAction()
 {
     $account = Cible_FunctionsGeneral::getAuthentication();
     if (!$account) {
         $this->_redirect(Cible_FunctionsPages::getPageNameByID(1, Zend_Registry::get('languageID')));
     }
     $productData = array();
     $cart = new Cart();
     if ($this->_isXmlHttpRequest) {
         $this->disableLayout();
         $this->disableView();
         $action = $this->_getParam('do');
         $productId = $this->_getParam('pId');
         $itemId = $this->_getParam('itemId');
         $quantity = $this->_getParam('quantity');
         $size = $this->_getParam('size');
         $category = $this->_getParam('category');
         $disable = $this->_getParam('disable');
         $cartId = $this->_getParam('cartItemsId');
         if ($action == 'update' && !empty($productId)) {
             if (!empty($size)) {
                 $cart->updateItem($productId, -1, array('CI_TailleID' => $size, 'CI_ItemID' => $itemId, 'CI_CartItemsID' => $cartId));
             } elseif (!empty($category)) {
                 $cart->updateItem($productId, -1, array('CI_CatTailleID' => $category, 'CI_ItemID' => $itemId, 'CI_CartItemsID' => $cartId));
             } else {
                 $oItem = new ItemsObject();
                 $oItem->setId($itemId);
                 $amount = $oItem->getPrice($quantity);
                 $cart->updateItem($productId, $quantity, array('CI_ItemID' => $itemId, 'CI_Total' => $amount, 'CI_CartItemsID' => $cartId));
             }
             echo 'updated';
         } elseif ($action == 'delete' && !empty($productId)) {
             if ($itemId && $cartId) {
                 $cart->updateItem($productId, 0, array('CI_ItemID' => $itemId, 'CI_CartItemsID' => $cartId));
                 echo 'deletedRow';
             } else {
                 $cart->updateItem($productId);
                 echo 'deleted';
             }
         } elseif ($action == 'disable' && !empty($productId)) {
             $cart->updateItem($productId, -1, array('CI_IsToSend' => $disable, 'CI_ItemID' => $itemId));
         } elseif ($action == 'addSize' && !empty($productId)) {
             $lastId = $cart->addSize(array('CI_ID' => $productId, 'CI_Quantity' => 1, 'CI_CatTailleID' => $category, 'CI_ItemID' => $itemId));
         } elseif ($action == 'getSizes' && !empty($category)) {
             $oSize = new TailleObject();
             $langId = $this->_getParam('langId');
             $size = $oSize->getDataByCategoryTailleId($category, $langId);
             echo json_encode($size);
             exit;
         }
     } else {
         $url = $this->view->absolute_web_root . $this->getRequest()->getPathInfo();
         $exclude = preg_match('/resume-order/', $url);
         if (!$exclude) {
             Cible_View_Helper_LastVisited::saveThis($url);
         }
         $urlBack = '';
         $urlNextStep = '';
         $urls = Cible_View_Helper_LastVisited::getLastVisited();
         if (count($urls) > 1) {
             $urlBack = $urls[1];
         }
         $account = Cible_FunctionsGeneral::getAuthentication();
         $profile = new MemberProfile();
         $memberData = $profile->findMember(array('email' => $account['email']));
         $memberData = $profile->addTaxRate($memberData);
         //            if ($memberData['validatedEmail'] == '')
         //                $this->view->assign('valide', true);
         //            else
         //                $this->view->assign('valide', false);
         $cartData = $cart->getAllIds();
         $allIds = $cartData['cartId'];
         if (count($allIds)) {
             $urlNextStep = $this->view->baseUrl() . '/' . Cible_FunctionsPages::getPageNameByID($this->_orderPageId, Zend_Registry::get('languageID')) . '/auth-order/';
         }
         $this->view->assign('itemCount', count($allIds));
         $this->view->assign('cartTotal', $cart->getTotalItem());
         $oProduct = new ProductsCollection();
         //            $orderPageId = Cible_FunctionsCategories::getPagePerCategoryView(0, 'order', 17);
         $resume = false;
         if ($this->_registry->pageID == $this->_orderPageId) {
             $resume = true;
         }
         foreach ($allIds as $key => $id) {
             $itemId = $cartData['itemId'][$key];
             $prodId = $cartData['prodId'][$key];
             $productData[$id] = $oProduct->getDetails($prodId, $itemId, $resume);
             $cartDetails = $cart->getItem($id, $itemId);
             if ($resume) {
                 $renderItem = $cart->renderResume($cartDetails, $itemId);
             } else {
                 $renderItem = $cart->renderCartLine($cartDetails, $itemId);
             }
             $productData[$id]['items']['render'] = $renderItem;
             $productData[$id]['cart']['disable'] = $cartDetails['Disable'];
             $productData[$id]['cart']['promoId'] = $cartDetails['PromoId'];
         }
         $hasBonus = $oProduct->getBonus();
         $orderParams = Cible_FunctionsGeneral::getParameters();
         $parameters = array('nbPoint' => 0, 'taxeProv' => $memberData['taxProv'], 'taxeCode' => $memberData['taxCode'], 'tpsFee' => $orderParams['CP_ShippingFees'], 'limitTpsFee' => $orderParams['CP_ShippingFeesLimit'], 'CODFees' => $orderParams['CP_MontantFraisCOD'], 'noProvTax' => $memberData['noProvTax'], 'noFedTax' => $memberData['noFedTax']);
         if ($memberData['taxCode'] == 'QC') {
             $parameters['taxeFed'] = $orderParams['CP_TauxTaxeFed'];
         }
         if ($hasBonus) {
             $parameters['nbPoint'] = $orderParams['CP_BonusPointDollar'];
         }
         $this->view->assign('productData', $productData);
         $this->view->assign('urlBack', $urlBack);
         $this->view->assign('nextStep', $urlNextStep);
         $this->view->assign('step', 1);
         $this->view->assign('hasBonus', $oProduct->getBonus());
         $this->view->assign('parameters', $parameters);
         if ($this->_registry->pageID == $this->_orderPageId) {
             $this->renderScript('index/cart-summary.phtml');
         } else {
             $this->renderScript('index/cart-details.phtml');
         }
     }
 }
Example #3
0
 /**
  * Method to reset item sequence call via url only
  */
 public function orderItemAction()
 {
     $oItem = new ItemsObject();
     $items = $oItem->getAll();
     $seq = 0;
     $prevProd = null;
     foreach ($items as $key => $item) {
         $prod = $item['I_ProductID'];
         if ($prod == $prevProd) {
             $seq += 10;
             $data['I_Seq'] = $seq;
             $oItem->save($item['I_ID'], $data, 1);
         } else {
             $seq = 10;
             $data['I_Seq'] = $seq;
             $oItem->save($item['I_ID'], $data, 1);
         }
         $prevProd = $item['I_ProductID'];
         var_dump($prod, $prevProd, $data['I_Seq']);
         var_dump('----------------');
     }
     exit;
 }
Example #4
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $labelCSS = Cible_FunctionsGeneral::getLanguageLabelColor($options);
     $imageSrc = $options['imageSrc'];
     $dataId = $options['dataId'];
     $imgField = $options['imgField'];
     $isNewImage = $options['isNewImage'];
     $moduleName = $options['moduleName'];
     if ($dataId == '') {
         $pathTmp = "../../../../../data/images/" . $moduleName . "/tmp";
     } else {
         $pathTmp = "../../../../../data/images/" . $moduleName . "/" . $dataId . "/tmp";
     }
     // Value of the shipping free
     $valueShippingFees = new Zend_Form_Element_Text('CP_ShippingFees');
     $valueShippingFees->setLabel($this->getView()->getCibleText('form_parameters_montant_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $valueShippingFees->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     // Value of the shipping fees limit
     $valueShippingFeesLimit = new Zend_Form_Element_Text('CP_ShippingFeesLimit');
     $valueShippingFeesLimit->setLabel($this->getView()->getCibleText('form_parameters_limit_transport_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $valueShippingFeesLimit->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     // Value of the COD
     $valueMontantFraisCOD = new Zend_Form_Element_Text('CP_MontantFraisCOD');
     $valueMontantFraisCOD->setLabel($this->getView()->getCibleText('form_parameters_COD_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $valueMontantFraisCOD->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     // Email for the command
     $valueAdminOrdersEmail = new Zend_Form_Element_Text('CP_AdminOrdersEmail');
     $valueAdminOrdersEmail->setLabel($this->getView()->getCibleText('form_parameters_email_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $valueAdminOrdersEmail->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     // Id of the free Item
     // List of products
     $oItems = new ItemsObject();
     $listItem = $oItems->itemsCollection(Zend_Registry::get('currentEditLanguage'));
     $itemID = new Zend_Form_Element_Select('CP_FreeItemID');
     $itemID->setLabel($this->getView()->getCibleText('form_parameters_free_item_label'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttrib('class', 'stdSelect')->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))));
     $itemID->addMultiOption('', $this->getView()->getCibleText('form_select_default_label'));
     $itemID->addMultiOptions($listItem);
     // Value of the minimum amount to have a free item
     $valueFreeMiniAmount = new Zend_Form_Element_Text('CP_FreeMiniAmount');
     $valueFreeMiniAmount->setLabel($this->getView()->getCibleText('form_parameters_free_item_minimum_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $valueFreeMiniAmount->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     // Value of the minimum amount to have a free item
     $valueBonusPointDollar = new Zend_Form_Element_Text('CP_BonusPointDollar');
     $valueBonusPointDollar->setLabel($this->getView()->getCibleText('form_parameters_bonus_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $valueBonusPointDollar->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     // Value of the canadian tax TPS
     $valueTauxTaxeFed = new Zend_Form_Element_Text('CP_TauxTaxeFed');
     $valueTauxTaxeFed->setLabel($this->getView()->getCibleText('form_parameters_taxe_label'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput');
     $label = $valueTauxTaxeFed->getDecorator('Label');
     $label->setOption('class', $this->_labelCSS);
     $this->addElement($valueShippingFees);
     $this->addElement($valueShippingFeesLimit);
     $this->addElement($valueMontantFraisCOD);
     $this->addElement($valueAdminOrdersEmail);
     $this->addElement($itemID);
     $this->addElement($valueFreeMiniAmount);
     $this->addElement($valueBonusPointDollar);
     $this->addElement($valueTauxTaxeFed);
 }
Example #5
0
 public function editAction()
 {
     // web page title
     $this->view->title = "Modification d'un produit";
     // variables
     $recordID = (int) $this->_getParam($this->_paramId);
     $returnAction = $this->_getParam('return');
     $baseDir = $this->view->baseUrl();
     $lang = $this->_getParam('lang');
     if (!$lang) {
         $this->_registry->currentEditLanguage = $this->_defaultEditLanguage;
     }
     $langId = (int) $this->_registry->currentEditLanguage;
     if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) {
         $cancelUrl = $baseDir . "/" . $this->_moduleTitle . "/" . $this->_name . "/" . $this->_defaultAction . "/";
         if ($returnAction) {
             $returnUrl = $this->_moduleTitle . "/" . $this->_name . "/" . $returnAction;
         } else {
             $returnUrl = $this->_moduleTitle . "/" . $this->_name . "/" . $this->_defaultAction . "/";
         }
         $oCollections = new ProductsObject();
         $collectionData = $oCollections->getAll($langId, true);
         $this->view->assign('collectionData', $collectionData);
         // get products details
         $oData = new ProductsObject();
         $record = $oData->populate($recordID, $langId);
         // image src.
         $config = Zend_Registry::get('config')->toArray();
         $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight'];
         $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth'];
         if (!empty($record[$this->_imageSrc])) {
             $this->view->assign('imageUrl', $this->_rootImgPath . $recordID . "/" . str_replace($record[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $record[$this->_imageSrc], $record[$this->_imageSrc]));
             $isNewImage = 'false';
         }
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($formData[$this->_imageSrc] != $record[$this->_imageSrc]) {
                 if ($formData[$this->_imageSrc] == "") {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = $this->_rootImgPath . $recordID . "/tmp/mcith/mcith_" . $formData[$this->_imageSrc];
                 }
                 $isNewImage = 'true';
             } else {
                 if ($record[$this->_imageSrc] == "") {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = $this->_rootImgPath . $recordID . "/" . str_replace($record[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $record[$this->_imageSrc], $record[$this->_imageSrc]);
                 }
             }
         } else {
             if (empty($record[$this->_imageSrc])) {
                 $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
             } else {
                 $imageSrc = $this->_rootImgPath . $recordID . "/" . str_replace($record[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $record[$this->_imageSrc], $record[$this->_imageSrc]);
             }
         }
         // generate the form
         $form = new FormProducts(array('moduleName' => $this->_moduleTitle . '/' . $this->_name, 'baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'imageSrc' => $imageSrc, 'imgField' => $this->_imageSrc, 'dataId' => $recordID, 'isNewImage' => true));
         $this->view->form = $form;
         // action
         if (!$this->_request->isPost()) {
             $association = new ProductsAssociationData();
             $selectAssociation = $association->select();
             $selectAssociation->where("AP_MainProductID = ?", $recordID);
             $associationFind = $association->fetchAll($selectAssociation)->toArray();
             $collectionChoice = array();
             foreach ($associationFind as $association) {
                 $collectionChoice[] = $association['AP_RelatedProductID'];
             }
             $this->view->assign('collectionChoice', $collectionChoice);
             $oItem = new ItemsObject();
             $itemList = $oItem->getAssociatedItems($recordID, $langId);
             $this->view->assign('renderItemsList', $itemList);
             $form->populate($record);
         } else {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $oData = new ProductsObject();
                 $newData = array_merge($formData['productFormLeft'], $formData['productFormRight'], $formData['productFormBotPub'], $formData['productFormBotPro']);
                 $formattedName = Cible_FunctionsGeneral::formatValueForUrl($newData['PI_Name']);
                 $newData['PI_ValUrl'] = $formattedName;
                 $oData->save($recordID, $newData, $langId);
                 // DELETE ASSOCIATION
                 $association = new ProductsAssociationData();
                 $where = "AP_MainProductID = " . $recordID;
                 $association->delete($where);
                 // ADD Association
                 if (array_key_exists("collectionSet", $formData)) {
                     foreach ($formData['collectionSet'] as $collectionID) {
                         $oAssociation = new ProductsAssociationData();
                         $associateData = $oAssociation->createRow();
                         $associateData->AP_MainProductID = $recordID;
                         $associateData->AP_RelatedProductID = $collectionID;
                         $associateData->save();
                     }
                 }
                 $newImage = $form->getSubForm('productFormRight')->getValue('isNewImage');
                 if ($newImage && $newData[$this->_imageSrc] != '') {
                     $config = Zend_Registry::get('config')->toArray();
                     $srcOriginal = $this->_imageFolder . $recordID . "/tmp/" . $newData[$this->_imageSrc];
                     $originalMaxHeight = $config[$this->_moduleTitle]['image']['original']['maxHeight'];
                     $originalMaxWidth = $config[$this->_moduleTitle]['image']['original']['maxWidth'];
                     $originalName = str_replace($newData[$this->_imageSrc], $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $newData[$this->_imageSrc], $newData[$this->_imageSrc]);
                     $srcMedium = $this->_imageFolder . $recordID . "/tmp/medium_" . $newData[$this->_imageSrc];
                     $mediumMaxHeight = $config[$this->_moduleTitle]['image']['medium']['maxHeight'];
                     $mediumMaxWidth = $config[$this->_moduleTitle]['image']['medium']['maxWidth'];
                     $mediumName = str_replace($newData[$this->_imageSrc], $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $newData[$this->_imageSrc], $newData[$this->_imageSrc]);
                     $srcThumb = $this->_imageFolder . $recordID . "/tmp/thumb_" . $newData[$this->_imageSrc];
                     $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight'];
                     $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth'];
                     $thumbName = str_replace($newData[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $newData[$this->_imageSrc], $newData[$this->_imageSrc]);
                     copy($srcOriginal, $srcMedium);
                     copy($srcOriginal, $srcThumb);
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcOriginal, 'maxWidth' => $originalMaxWidth, 'maxHeight' => $originalMaxHeight));
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcMedium, 'maxWidth' => $mediumMaxWidth, 'maxHeight' => $mediumMaxHeight));
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcThumb, 'maxWidth' => $thumbMaxWidth, 'maxHeight' => $thumbMaxHeight));
                     rename($srcOriginal, $this->_imageFolder . $recordID . "/" . $originalName);
                     rename($srcMedium, $this->_imageFolder . $recordID . "/" . $mediumName);
                     rename($srcThumb, $this->_imageFolder . $recordID . "/" . $thumbName);
                 }
                 if ($formData['Status'] == 0) {
                     $formData['Status'] = 2;
                 }
                 // redirect
                 if (isset($formData['submitSaveClose'])) {
                     $this->_redirect($returnUrl);
                 } else {
                     $this->_redirect($this->_moduleTitle . "/" . $this->_name . "/edit/productID/" . $recordID);
                 }
             } else {
                 if (array_key_exists("collectionSet", $formData)) {
                     $this->view->assign('collectionChoice', $formData['collectionSet']);
                 } else {
                     $this->view->assign('collectionChoice', array());
                 }
                 $form->populate($record);
             }
         }
     }
 }
Example #6
0
 public function getDetails($id, $itemId = 0, $resume = false)
 {
     $products = array();
     $originalId = 0;
     $oProduct = new ProductsObject();
     $oItem = new ItemsObject();
     if ($resume) {
         $oItem->setRenderResume($resume);
     }
     $products['data'] = $oProduct->populate($id, Zend_Registry::get('languageID'));
     $hasBonus = $products['data']['P_CumulPoint'];
     if (!$this->_bonus && $hasBonus) {
         $this->_bonus = $hasBonus;
     }
     if ($itemId) {
         $products['items'] = $oItem->populate($itemId, Zend_Registry::get('languageID'));
     }
     return $products;
 }
Example #7
0
 private function manageItemPromo($id, $itemId)
 {
     // Chercher itemId dans la table des promo dans le champ IP_ConditionItemId
     $oItemPromo = new ItemsPromoObject();
     $oItem = new ItemsObject();
     $dataPromo = $oItemPromo->getAssociatedItems($itemId);
     // Si trouvé,
     if (count($dataPromo) > 0) {
         //  Récupré le nombre d'itemId dans le cart
         $detail = $this->getItem($id, $itemId);
         $nbItemInCart = $detail['Quantity'];
         foreach ($dataPromo as $promo) {
             $itemData = $oItem->getAll(null, true, $promo['IP_ItemId']);
             $promo['I_ProductID'] = $itemData[0]['I_ProductID'];
             //  Comparer avec le champ IP_NbItem
             //  Si le nombre dans cart sup à qté dans table promo
             if ($nbItemInCart >= $promo['IP_NbItem']) {
                 //      Tester si l'item promo existe déjà
                 //      Si non: Ajouter dans la table CartItems
                 if (!$this->alreadyInCart($promo['I_ProductID'], $promo['IP_ItemId'], $promo['IP_ID'])) {
                     $this->_insertPromo($promo);
                 }
             } elseif ($promo['IP_NbItem'] == 0) {
                 // Si le nombre d'item conditionnel est null, alors on test
                 // sur le total
                 $this->_testByTotal($promo, $oItem);
             } else {
                 $this->_db->delete('CartItems', array("CI_PromoId = {$promo['IP_ID']}", 'CI_Disable != 1'));
             }
         }
     } else {
         // Si itemId <>
         $dataPromo = $oItemPromo->getAll();
         foreach ($dataPromo as $promo) {
             $this->_testByTotal($promo, $oItem);
         }
     }
 }
Example #8
0
 /**
  * Calculation of taxes and amounts for orders rendrering.
  *
  * @param array $memberInfos
  * @param bool $lines
  *
  * @return array
  */
 public function calculateTotal($memberInfos, $lines = false)
 {
     $session = new Zend_Session_Namespace('order');
     $data = array();
     $oCart = new Cart();
     $oItem = new ItemsObject();
     $oProd = new ProductsCollection();
     $subTotProv = 0;
     $subTotFed = 0;
     $subTot = 0;
     $total = 0;
     $taxProv = 0;
     $taxFed = 0;
     $tmpSum = 0;
     $nbPoint = 0;
     $cartData = $oCart->getAllIds();
     $orderParams = Cible_FunctionsGeneral::getParameters();
     if (!$memberInfos['noFedTax'] && $session->stateId == 11) {
         foreach ($cartData['cartId'] as $key => $id) {
             $itemId = $cartData['itemId'][$key];
             $prodId = $cartData['prodId'][$key];
             $itemDetails = $oItem->getAll(null, true, $itemId);
             $cartDetails = $oCart->getItem($id, $itemId, true);
             if ($itemDetails[0]['I_TaxFed']) {
                 $subTotFed += $cartDetails['Total'];
             }
         }
         $addShipFee = Cible_FunctionsGeneral::compareFloats($subTotFed, '<', $orderParams['CP_ShippingFeesLimit'], 2);
         if ($addShipFee) {
             $subTotFed += $orderParams['CP_ShippingFees'];
         }
         if (isset($session->order['cod'])) {
             $subTotFed += $orderParams['CP_MontantFraisCOD'];
         }
         $taxFed = Cible_FunctionsGeneral::federalTax($subTotFed);
     }
     if (!$memberInfos['noProvTax']) {
         foreach ($cartData['cartId'] as $key => $id) {
             $itemId = $cartData['itemId'][$key];
             $prodId = $cartData['prodId'][$key];
             $itemDetails = $oItem->getAll(null, true, $itemId);
             $cartDetails = $oCart->getItem($id, $itemId, true);
             if ($itemDetails[0]['I_TaxProv']) {
                 $subTotProv += $cartDetails['Total'];
             }
         }
         $addShipFee = Cible_FunctionsGeneral::compareFloats($subTotProv, '<', $orderParams['CP_ShippingFeesLimit'], 2);
         if ($addShipFee) {
             $subTotProv += $orderParams['CP_ShippingFees'];
         }
         if (isset($session->order['cod'])) {
             $subTotProv += $orderParams['CP_MontantFraisCOD'];
         }
         $taxProv = Cible_FunctionsGeneral::provinceTax($subTotProv);
     }
     foreach ($cartData['cartId'] as $key => $id) {
         $itemId = $cartData['itemId'][$key];
         $prodId = $cartData['prodId'][$key];
         $productData = $oProd->getDetails($prodId);
         $cartDetails = $oCart->getItem($id, $itemId, true);
         $subTot += $cartDetails['Total'];
         if ($oProd->getBonus()) {
             $nbPoint += ceil($cartDetails['Total'] * $orderParams['CP_BonusPointDollar']);
         }
     }
     $addShipFee = Cible_FunctionsGeneral::compareFloats($subTot, '<', $orderParams['CP_ShippingFeesLimit'], 2);
     if ($addShipFee) {
         $tmpSum += $orderParams['CP_ShippingFees'];
     }
     if (isset($session->order['cod'])) {
         $tmpSum += $orderParams['CP_MontantFraisCOD'];
     }
     $total = $subTot + $tmpSum + round($taxFed, 2) + round($taxProv, 2);
     $data = array('subTotProv' => $subTotProv, 'subTotFed' => $subTotFed, 'subTot' => $subTot, 'total' => $total, 'taxProv' => $taxProv, 'nbPoint' => $nbPoint, 'taxFed' => $taxFed);
     return $data;
 }