Current File : /home/k/a/r/karenpetzb/www/items/category/utils.zip
PKVH[>�B/RRItemCaddyType.phpnu&1i�<?php
class ItemCaddyType {
	var $id;
	var $qte;

	var $idProduit;
	var $idChild;
	var $idBrend;
	var $nom;
	var $descshort;
	var $navnom;
	var $navnom_urlparents;
	var $url;
	var $designation;
	var $stock = 1;
	var $isAccessoire = 'N';
    var $selectedOption = ""; 

	var $remise_euro = 0;
	var $remise_pour = 0;
	var $isActif;
	var $reference;
	var $idcategory;
	var $promo_date; 

	var $isDevis;
	var $prix;
	var $qte_min;
	
	
	var $isPromoCaddyType = false;

	function ItemCaddyType() { }

	function getItemInfo($id, $qte, $selectedOption) {
		$userCaddyType = new UserCaddyType();
		$result = $userCaddyType->getArticleByCaddyId($id);
			
		$this->id = $id;
		$this->idChild = $result['IDCHILD'];
		$this->idBrend = $result['IDBREND'];
		$this->qte = $qte;
		$this->idProduit = $result['IDPRODUCT'];
		$this->nom = $result['NOM'];
		$this->descshort = $result['DESCSHORT'];
		$this->navnom = $result['NAVNOM'];
		$this->url = $result['URL'];
		$this->designation = $result['DESIGNATION'];
		$this->stock = $result['STOCK'];

		$this->remise_euro = $result['REMISEEURO'];
		$this->remise_pour = $result['REMISEPOUR'];
		$this->isActif = $result['isCADDYTYPE_ACTIF'];

		$this->reference = $result['REFERENCE'];
		$this->idcategory = $result['IDCATEGORY'];
		$this->promo_date = $result['DATEPROMO'];
		
		$this->isDevis = $result['isDEVIS'];
		$this->prix = $result['PRIX'];
		$this->qte_min = $result['QUANTITYMIN']; 
		$this->selectedOption = $selectedOption;
	}

	public function setLineInfo($result, $qte) {
		$this->id = $result['CADDYTYPEID'];
		$this->idChild = $result['IDCHILD'];
		$this->idBrend = $result['IDBREND'];
		$this->qte = $qte;
		$this->idProduit = $result['IDPRODUCT'];
		$this->nom = $result['NOM'];
		$this->descshort = $result['DESCSHORT'];
		$this->navnom = $result['NAVNOM'];
		$this->navnom_urlparents = $result['NAVNOM_URLPARENTS'];
		$this->url = $result['URL'];
		$this->designation = $result['DESIGNATION'];
		$this->stock = $result['STOCK'];

		$this->remise_euro = $result['REMISEEURO'];
		$this->remise_pour = $result['REMISEPOUR'];
		$this->isActif = $result['isCADDYTYPE_ACTIF'];

		$this->reference = $result['REFERENCE'];
		$this->idcategory = $result['IDCATEGORY'];
		$this->promo_date = $result['DATEPROMO'];
		
		$this->isDevis = $result['isDEVIS'];
		$this->prix = $result['PRIX'];
		$this->qte_min = $result['QUANTITYMIN']; 
		
		$selectedOption_tmp = '';
		$optionList = new OptionList();
		$item_optionsByList = $optionList->getByIdProduct($result['IDPRODUCT']);
		if (!empty($item_optionsByList) && !empty($item_optionsByList->values)) {
			foreach($item_optionsByList->values as $currentOption) {	
				$selectedOption_tmp = $currentOption;
				break;
			}
		}	 
		$this->selectedOption = $selectedOption_tmp;
	}

	public function isActif() {
		if($this->isActif == 'Y') { return true ;}
		return false;
	}

	public function isPromo() {
		if ($this->remise_euro > 0 || $this->remise_pour > 0) {  return true; }
		return false;
	}

	public function setRemise($euro, $pour) {
		if ($euro > 0) { $this->remise_euro = $euro; }
		else if ($pour > 0) { $this->remise_pour = $pour; }
	}

	public function isRemiseChanged() {
		if ($this->remise_euro > 0 || $this->remise_pour > 0) { return true; }
		return false;
	}

	public function isSurDevis() {
		if ($this->isDevis == 0) { return true; }
		return false;
	}

	public function getPrixAfterRemise() {
		if ($this->remise_euro > 0) {
			return sprintf("%.2f",$this->prix - $this->remise_euro);
		} else if ($this->remise_pour > 0) {
			return sprintf("%.2f",$this->prix - (($this->prix * $this->remise_pour) / 100));
		}
		return sprintf("%.2f",$this->prix);
	}

}

?>
PKVH[_a��Facture.phpnu&1i�<?php
class Facture {
 
	var $facture_fidelite_lines;
	var $facture_lines;
	var $code_reduction; 
	var $livraison;

	var $remise_command_euro = 0;
	var $remise_command_pour = 0;
	var $date_start;

	var $total_poids = 0;
	var $isAncienPoids = false;
	var $isFrancoDenied = false;
	var $isCodeReduction_Product = false;

	var $total_HT_HR = 0;
	var $total_remise = 0;
	var $total_HT = 0;
	var $total_frais_port = 0;
	var $total_frais_port_pour = 0;
	var $total_HT_FP = 0;
	var $total_TVA = 0;
	var $total_TTC = 0;

	var $resteFrancoLiv;
	
	//Dans le casdes caddyType
	var $user_nom;
	var $user_prenom;
	var $user_id;
	  
	function Facture() {
		$this->facture_lines = array();
		$this->facture_fidelite_lines = array();
		$this->code_reduction = array();
		$this->livraison = array();
		 
		$this->setDateStart();
	}

	 
	public function changeTVA($newTVA) {
		$this->tva = $newTVA;
		$this->total_TVA = $this->getPrixTotalTVA(false);
		$this->total_TTC = $this->getPrixTotalTTC(false);
	}

	public function isFactureValid($type) {
		if (isset($this->facture_lines) && !empty($this->facture_lines)) { return true; }
		return false;
	}

	public function checkCodeReductionProduct($reference, $qte) {
		if (isset($this->code_reduction) && !empty($this->code_reduction)) {
			if (($reference == $this->code_reduction['PRODUITREF']) && ($qte >= $this->code_reduction['PRODUITNBR'])) {
				$this->isCodeReduction_Product = true;
			}
		}
	}

	public function getPrixCodeReduction() {
		if (isset($this->code_reduction) && !empty($this->code_reduction) && $this->code_reduction['isACTIF'] == 1 ) {
			if ($this->code_reduction['EURO'] > 0) {
				return sprintf("%.2f",$this->code_reduction['EURO']);
			}
			if ($this->code_reduction['POUR'] > 0) {
				return ($this->total_HT_HR * $this->code_reduction['POUR']) / 100;
			}
		}
		return 0;
	}

	public function getPrixRemise() {
		$result = 0;
		if ($this->remise_command_euro > 0) { $result = $this->remise_command_euro; }
		if ($this->remise_command_pour > 0) { $result += ($this->total_HT_HR * $this->remise_command_pour) / 100; }
		return sprintf("%.2f",$result);
	}

	public function getPrixTotalHT() {
		$prixRemise = $this->getPrixRemise();
		if ($prixRemise >= $this->total_HT_HR) {
			$this->remise_command_euro = 0;
			$this->remise_command_pour = 0;
			$prixRemise = 0;
		}
		return sprintf("%.2f",$this->total_HT_HR - $prixRemise);
	}

	public function getPrixTotalHT_FP($isShow) {
		if ($isShow) { return sprintf("%.2f",$this->total_HT + $this->total_frais_port, 2, ',', ' '); }
		return sprintf("%.2f",$this->total_HT + $this->total_frais_port);
	}

	public function getPrixTotalTVA($isShow) {
		if ($isShow) { return sprintf("%.2f", ($this->getPrixTotalHT_FP(false) * $this->getCurrentTva($this->date_start)) / 100, 2, ',', ' '); }
		return sprintf("%.2f", ($this->getPrixTotalHT_FP(false) * $this->getCurrentTva($this->date_start)) / 100);
	}

	public function getPrixTotalTTC($isShow) {
		if ($isShow) { return sprintf("%.2f", $this->getPrixTotalHT_FP(false) + $this->getPrixTotalTVA(false) , 2, ',', ' '); }
		return sprintf("%.2f", $this->getPrixTotalHT_FP(false) + $this->getPrixTotalTVA(false));
	}

	public function getNbArticles() {
		if (isset($this->facture_lines) && !empty($this->facture_lines)) { return count($this->facture_lines); }
		return 0;
	} 
	public function addLine($line) { 
		array_push($this->facture_lines, $line); 
	}
	public function addFideliteLine($line) { 
		array_push($this->facture_fidelite_lines, $line); 
	}

	public function toArray() {	}

	private function setDateStart() {
		$date = new Zend_Date();
		$this->date_start = $date->toString('YYYY-MM-dd HH:mm:ss');
	}
	
	private function getCurrentTva($datevalue) {
		$date = new Zend_Date();
		$date->set($datevalue);
		$result = 20;
		if (intval($date->toString('YYYY')) < 2014) {
			$result = 19.60;
		}
		return $result;
	}
	
	public function computeFactureTVA(&$facture, $paysLivraison) {
		$resultTVA = $this->getCurrentTva($facture['DATESTART']);
		
		try {
			/*if (isset($paysLivraison) && !empty($paysLivraison)) {
			 if (strcasecmp($paysLivraison, "FRANCE") != 0) {
			$resultTVA = 0;
			}
			}*/
			if (isset($facture) && !empty($facture)) {
				$facture['TVA'] = $resultTVA;
				$facture['PRIXTOTALTVA'] = sprintf("%.2f", $facture['PRIXTOTALHTFP'] * $facture['TVA']) / 100;
				
			}
		} catch(Zend_Exception $e) { }
	}
    
    public function isCarteFidelitePointsValid($sumOfUser) {
        return $this->getCarteFidelitePointsTotal() <= $sumOfUser;
    }
    public function getCarteFidelitePointsTotal() {
        $total = 0;
		foreach ($this->facture_fidelite_lines as $item) {
            $total += $item->fidelite_nbpoint;
        }
        return $total;
    }
	
}

?>PKVH[�����CaddyFidelite.phpnu&1i�<?php
class CaddyFidelite {
	var $items = array(); 

	function CaddyFidelite() {
		$this->items = array(); 
	}
    
	function removeItem($idfidelite){
        $newItems = array(); 
        foreach($this->items as $item) { 
			if ($item->idFidelite != $idfidelite) {
			    array_push($newItems, $item);
			} 
		}  
        $this->items = $newItems;
    }
	function addItem($idfidelite){
		$currentItem = false;  
		foreach($this->items as $item) { 
			if ($item->idFidelite == $idfidelite) {
				$currentItem = true;  
			} 
		}    
		if ($currentItem == false) {
			$item = new ItemFidelite();
			$item->getItemInfo($idfidelite);
            if (!empty($item->nom)) {
			    array_push($this->items, $item);
            }
		} 
	} 
}

?>PKVH[�9��	Caddy.phpnu&1i�<?php
class Caddy {
	var $items;
	var $itemsCaddyType;

	function Caddy() {
		$this->items = array();
		$this->itemsCaddyType = array();
	}
	
	private function getStorage() {
		$registry = Zend_Registry::getInstance();
		$setting = $registry->get('setting');
		return new Zend_Auth_Storage_Session($setting->session_storage);
	}
	
	function getTotalSize() {
		$result = 0;
        
		if (isset($this->items) && !empty($this->items)) { $result += sizeof($this->items); }
		
		$auth = Zend_Auth::getInstance();
		$auth->setStorage($this->getStorage());
		$storage = $auth->getStorage()->read(); 
		if ($auth->hasIdentity() && isset($storage['user']) && $storage['user']['iscaddytype'] == 'Y') {
			if (isset($this->itemsCaddyType) && !empty($this->itemsCaddyType)) { $result += sizeof($this->itemsCaddyType); }
		} 
		return $result;
	}

	function cleanUp() {
		$this->items = array();
		$this->itemsCaddyType = array();
	}

	function addItemToCaddy($idChild, $qteChild, $isAccessoire, $selectedOption){
		$currentItem = false;  
		foreach($this->items as $key => $item) { 
			if ($item->idChild == $idChild && $item->selectedOption == $selectedOption) {
				$item->qteChild = $qteChild; 
				$currentItem = true;  
			} 
		}    
		if ($currentItem == false) {
			$item = new Item();
			$item->getItemInfo($idChild, $qteChild, $isAccessoire, $selectedOption);
			array_push($this->items, $item);
		} 
	}
	function addItemToCaddyType($idCaddyType, $qte, $selectedOption){
		$currentItem = false;
		foreach($this->itemsCaddyType as $item) {
			if ($item->id == $idCaddyType && $item->selectedOption == $selectedOption) {
				$item->qte = $qte;
				$currentItem = true;
				break;
			}
		}
		if ($currentItem == false) {
			$itemCaddyType = new ItemCaddyType();
			$itemCaddyType->getItemInfo($idCaddyType, $qte, $selectedOption);
			array_push($this->itemsCaddyType, $itemCaddyType);
		}
	}
	function delItemToCaddyType($idCaddyType, $selectedOption){
		$currentKey = -1;
		foreach($this->itemsCaddyType as $key => $item) {
			if ($item->id == $idCaddyType && $item->selectedOption == $selectedOption) {
				$currentKey = $key; 
				break;
			}
		}
		if ($currentKey != -1) { unset($this->itemsCaddyType[$currentKey]); }
		if (!is_array($this->itemsCaddyType)) {  $this->itemsCaddyType = array(); }
		$tmp = $this->itemsCaddyType;
		$this->itemsCaddyType = array_values($tmp); 
	}

	function delItemToCaddy($idChild, $selectedOption){
		$currentKey = -1; 
		foreach($this->items as $key => $item) {
			if ($item->idChild == $idChild && $item->selectedOption == $selectedOption) {
				$currentKey = $key;
				break;
			}
		} 
		if ($currentKey != -1) { unset($this->items[$currentKey]); }
		if (!is_array($this->items)) {  $this->items = array(); }
		$tmp = $this->items;
		$this->items = array_values($tmp);
	}
	
	function delItemToCaddyByKey($currentKey){  
		if ($currentKey != -1) { unset($this->items[$currentKey]); }
		if (!is_array($this->items)) {  $this->items = array(); }
		$tmp = $this->items;
		$this->items = array_values($tmp);
	}

	function getQuantity($idChild) {
		if (!empty($this->items)) {
			foreach($this->items as $item) {
				if ($item->idChild == $idChild) {
					return $item->qteChild;
				}
			}
		}
		return 0;
	}

	function getItemById($idChild) {
		foreach($this->items as $item) {
			if ($item->idChild == $idChild) {
				return $item;
			}
		}
		return null;
	}

	function getItemByIdAndOption($idChild, $selectedOption) {
		foreach($this->items as $item) {
			if ($item->idChild == $idChild && $item->selectedOption == $selectedOption) {
				return $item;
			}
		}
		return null;
	}

	function getItemCaddyTypeByIdChild($idChild) {
		foreach($this->itemsCaddyType as $item) {
			if ($item->idChild == $idChild) {
				return $item;
			}
		}
		return null;
	}

	function getItemCaddyTypeByIdChildAndOption($idChild, $selectedOption) {
		foreach($this->itemsCaddyType as $item) {
			if ($item->idChild == $idChild && $item->selectedOption == $selectedOption) {
				return $item;
			}
		}
		return null;
	}

	function getCaddyTemp($userId) {

		$this->items = array();
		$caddyTemp = new CaddyTemp();
		$resultCaddy = $caddyTemp->findCaddyByUser($userId);

		if (isset($resultCaddy) && !empty($resultCaddy)) {
			foreach ($resultCaddy AS $row) {
				$item = new Item();

				$item->idChild = $row['CHILDID'];
				$item->qteChild = $row['CHILDQUANTITY'];
				$item->idProduit = $row['PRODUCTID'];
				$item->nom = $row['PRODUCTNOM'];
				$item->descshort = $row['DESCSHORT'];
				$item->navnom = $row['NAVNOM'];
				$item->url = $row['URL'];
				$item->designation = $row['DESIGNATION'];
				$item->isAccessoire = $row['isACCESSOIRE'];
				$item->selectedOption = $row['SELECTEDOPTION'];
				$item->stock = 1;

				array_push($this->items, $item);
			}
		}
	}

	function showCaddy() {
		foreach($this->items as $item) {
			print $item->toString()."<br/>";
		}
	}
}

?>PKVH[tS�U�4�4PromoCalculator.phpnu&1i�<?php
class PromoCalculator {
	var $promoProduct;
	var $promoUser;
	var $promoCommand;

	function PromoCalculator() {
		$this->promoProduct = new PromoProduct();
		$this->promoUser = new PromoUser();
		$this->promoCommand = new PromoCommand();
	}

	public function calculEuro($prix, $remise) { return $prix - $remise; }
	public function calculPour($prix, $remise) { return $prix - (($prix * $remise) / 100); }
	public function isRemise() {

	}
	/*
	 * REMISES SUR PRODUITS
	 */

	/*
	 * Calcul du prix de la promotion selon la reference d'un produit
	 */
	private function computePrixProductByReference($factureLine) {
		if ($factureLine->isPromo()) {
			$myPromo = $this->promoProduct->getRemiseByProductReference($factureLine->item_reference);
			if ($myPromo['REMISEEURO'] > 0) {
				$factureLine->remise_euro = $myPromo['REMISEEURO'];
				//$prixPromo = $this->calculEuro($factureLine->item_prix, $myPromo['REMISEEURO']);
				//$factureLine->setPrixPromo($prixPromo);
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				//$prixPromo = $this->calculPour($factureLine->item_prix, $myPromo['REMISEPOUR']);
				//$factureLine->setPrixPromo($prixPromo);
				$factureLine->remise_pour = $myPromo['REMISEPOUR'];
			}
			$factureLine->checkPrixPromo();
		}
	}

	/*
	 * Calcul du prix de la promotion selon la marque d'un produit
	 */
	private function computePrixProductByMarque($factureLine) {
		$myPromo = $this->promoProduct->getRemiseByProductBrend($factureLine->product_brend_id);
		if ($myPromo) {
			if ($myPromo['REMISEEURO'] > 0) {
				$factureLine->remise_euro = $myPromo['REMISEEURO'];
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				$factureLine->remise_pour = $myPromo['REMISEPOUR'];
			}
			$factureLine->checkPrixPromo();
		}
	}


	/*
	 * Calcul du prix de la promotion selon la gamme d'un produit
	 */
	private function computePrixProductByCategory($factureLine) {
		$myPromo = $this->promoProduct->getRemiseByProductCategory($factureLine->product_category_id);
		if ($myPromo) {
			if ($myPromo['REMISEEURO'] > 0) {
				$factureLine->remise_euro = $myPromo['REMISEEURO'];
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				$factureLine->remise_pour = $myPromo['REMISEPOUR'];
			}
			$factureLine->checkPrixPromo();
		}
	}

	/*
	 * Calcul du prix de la promotion d'un produit selon un nombre achete
	 */
	private function computePrixProductByQte($factureLine, $facture_lines) {
		$myPromo = $this->promoProduct->getRemisesByProductQte($factureLine->item_reference, $factureLine->item_qte);
		if ($myPromo) {
			foreach ($facture_lines AS $line) {
				foreach ($myPromo AS $promo) {
					if (($line->item_reference == $promo['CHILDREFBUY']) &&
					($line->item_qte >= $promo['CHILDREFBUYNB']) ) {
						if ($promo['REMISEEURO'] > 0) {
							$factureLine->remise_items = array(
								'NB' => $promo['CHILDREFPROMONB'],
								'REF' => $promo['CHILDREFPROMO'],
								'REMISE_EURO' => $promo['REMISEEURO'],
								'REMISE_POUR' => 0

							);
						}
						if ($promo['REMISEPOUR'] > 0) {
							$factureLine->remise_items = array(
								'NB' => $promo['CHILDREFPROMONB'],
								'REF' => $promo['CHILDREFPROMO'],
								'REMISE_POUR' => $promo['REMISEPOUR'],
								'REMISE_EURO' => 0 
							);
						}
					}
				}
			}
		}
	}

	/*
	 * Calcul du prix de la promotion selon la date d'un produit
	 */
	private function computePrixProductByDateBetween($factureLine) {
		$myPromo = $this->promoProduct->getRemiseByProductDateBetween($factureLine->product_promo_date);
		if ($myPromo) {
			if ($myPromo['REMISEEURO'] > 0) {
				$factureLine->remise_euro = $myPromo['REMISEEURO'];
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				$factureLine->remise_pour = $myPromo['REMISEPOUR'];
			}
			$factureLine->checkPrixPromo();
		}
	}


	/*
	 * Calcul du prix de la remise selon la marque et l'user
	 */
	private function computePrixUserByMarque($factureLine, $userId) {
		$myPromo = $this->promoUser->getRemiseByMarque($factureLine->product_brend_id, $userId);
		if ($myPromo) {
			if ($myPromo['REMISEEURO'] > 0) {
				$factureLine->remise_euro = $myPromo['REMISEEURO'];
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				$factureLine->remise_pour = $myPromo['REMISEPOUR'];
			}
			$factureLine->checkPrixPromo();
		}
	}

	/*
	 * Calcul du prix de la remise selon le code interne et la marque
	 */
	private function computePrixUserByCodeInternMarque($factureLine, $codeIntern) {
		$myPromo = $this->promoUser->getRemiseByCodeInternMarque($factureLine->product_brend_id, $codeIntern);
		if ($myPromo) {
			if ($myPromo['REMISEEURO'] > 0) {
				$factureLine->remise_euro = $myPromo['REMISEEURO'];
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				$factureLine->remise_pour = $myPromo['REMISEPOUR'];
			}
			$factureLine->checkPrixPromo();
		}
	}


	/*
	 * REMISES GLOBALES
	 */

	/*
	 * Calcul du prix de la remise de la commande selon un nombre de produits
	 *
	 * CUMUL
	 */
	private function computePrixCommandByProductQte($factureLine, $facture) {
		$myPromo = $this->promoCommand->getRemiseCommandByProductQte($factureLine->item_reference, $factureLine->item_qte);
		if ($myPromo) {
			if ($myPromo['REMISEEURO'] > 0) {
				$facture->remise_command_euro += $myPromo['REMISEEURO'];
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				$facture->remise_command_pour += $myPromo['REMISEPOUR'];
			}
		}
	}

	/*
	 * Calcul du prix de la remise de la commande selon le TOTAL HT
	 *
	 * CUMUL
	 */
	private function computePrixCommandByTotalHT($facture) {
		$myPromo = $this->promoCommand->getRemiseCommandByTotalHT($facture->total_HT_HR);
		if ($myPromo) {
			if ($myPromo['REMISEEURO'] > 0) {
				$facture->remise_command_euro += $myPromo['REMISEEURO'];
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				$facture->remise_command_pour += $myPromo['REMISEPOUR'];
			}
		}
	}

	/*
	 * Calcul du prix de la remise de toute les commandes
	 *
	 * CUMUL
	 */
	private function computePrixCommandByAll($facture) {
		$myPromo = $this->promoCommand->getRemiseCommandByAll();
		if ($myPromo) {
			if ($myPromo['REMISEEURO'] > 0) {
				$facture->remise_command_euro += $myPromo['REMISEEURO'];
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				$facture->remise_command_pour += $myPromo['REMISEPOUR'];
			}
		}
	}

	/*
	 * Calcul du prix de la remise de la commande selon la date anniversaire
	 *
	 * CUMUL
	 */
	private function computePrixUserByDateInscription($facture, $dateInsc) {
		$myPromo = $this->promoUser->getRemiseByDateInscription();
		if ($myPromo) {
			$date = new Zend_Date();
			$userDate = new Zend_Date(strtotime($dateInsc));
			if (($userDate->toString("MM") -  $date->toString("MM")) < 2 &&
			($userDate->toString("MM") -  $date->toString("MM")) > -2) {
					
				if ($myPromo['REMISEEURO'] > 0) {
					$facture->remise_command_euro += $myPromo['REMISEEURO'];
				}
				if ($myPromo['REMISEPOUR'] > 0) {
					$facture->remise_command_pour += $myPromo['REMISEPOUR'];
				}
			}
		}
	}


	/*
	 * Calcul du prix de la remise de la commande selon l'user
	 *
	 * CUMUL
	 */
	private function computePrixUserByUser($facture, $userID) {
		$myPromo = $this->promoUser->getRemiseByUserID($userID);
		if ($myPromo) {
			if ($myPromo['REMISEEURO'] > 0) {
				$facture->remise_command_euro += $myPromo['REMISEEURO'];
			}
			if ($myPromo['REMISEPOUR'] > 0) {
				$facture->remise_command_pour += $myPromo['REMISEPOUR'];
			}
		}
	}

	/*
	 * Calcul du prix de la remise de la commande si c'est la premiere
	 *
	 * CUMUL
	 */
	private function computePrixUserByIsFirstCommand($facture, $userID) {
		$myPromo = $this->promoUser->getRemiseByIsFirstCommand();
		if ($myPromo) {
			$commande = new Command();
			if (!$commande->isAlreadyBuySomething($userID)) {
				if ($myPromo['REMISEEURO'] > 0) {
					$facture->remise_command_euro += $myPromo['REMISEEURO'];
				}
				if ($myPromo['REMISEPOUR'] > 0) {
					$facture->remise_command_pour += $myPromo['REMISEPOUR'];
				}
			}
		}
	}

	/*
	 * Calcul du prix du code de reduction pour un produit
	 *
	 * UNIQUE
	 */
	private function computePrixCodeReduction($facture) {
		if (isset($facture->code_reduction) && !empty($facture->code_reduction)) {
			$codeReduction = new CodeReduction();
			$myPromo = $codeReduction->getVerifyCodeBy($facture->code_reduction['CODE']);
			if ($myPromo) {
				$facture->code_reduction = $myPromo;
				if ($facture->isCodeReduction_Product) {
					if (isset($myPromo) && !empty($myPromo) && $myPromo['isACTIF'] == 1 ) {
						if ($myPromo['EURO'] > 0) {
							$facture->remise_command_euro = $myPromo['EURO'];
						}
						if ($myPromo['POUR'] > 0) {
							$facture->remise_command_pour = $myPromo['POUR'];
						}
					}
				} else {
					if ($facture->total_HT_HR >= $myPromo['CMDTOTAL'] && $myPromo['CMDTOTAL'] > 0) {
						if ($myPromo['EURO'] > 0) {
							$facture->remise_command_euro = $myPromo['EURO'];
						}
						if ($myPromo['POUR'] > 0) {
							$facture->remise_command_pour = $myPromo['POUR'];
						}
					}
				}
				$facture->code_reduction['EURO'] = $facture->getPrixCodeReduction();
			} else { $facture->code_reduction = array(); }
		}
	}

	/*
	 * Calcul du prix restant a payer de la commande pour validation
	 *
	 * Return prix restant a payer
	 */
	public function getPrixCommandValidation($facture) {
		$result = 0;
		$myPromo = $this->promoCommand->getCommandValid();
		if ($myPromo) {
			$total_HT = $facture->getPrixTotalHT();
			if ($total_HT < $myPromo['MONTANTVALID']) {
				$result = sprintf("%.2f", $myPromo['MONTANTVALID'] - $total_HT);
			}
		}
		return $result;
	}
	public function isCommandValid($prixHT) {
		$myPromo = $this->promoCommand->getCommandValid();
		if ($myPromo) {
			if ($prixHT < $myPromo['MONTANTVALID']) {  return false ; }
		}
		return true;
	}



	public function computeAllPromos($facture, $user) {
		foreach ($facture->facture_lines AS $item) {
			if (!$item->isCaddyType) {
				if ($item->isSurDevis()) {
					$item->item_prix = 0;
				} else {
					$this->computePrixProductByReference($item);
					if (!$item->isRemiseChanged()) { $this->computePrixProductByMarque($item); }
					if (!$item->isRemiseChanged()) { $this->computePrixProductByCategory($item); }
					if (!$item->isRemiseChanged()) { $this->computePrixProductByQte($item, $facture->facture_lines); }
					if (!$item->isRemiseChanged()) { $this->computePrixProductByDateBetween($item); }


					if (isset($user) && !empty($user)) {
						$userId = $user['id'];
						$codeIntern = $user['cintern'];

						if (!empty($codeIntern)) { $this->computePrixUserByCodeInternMarque($item, $codeIntern); }
						if (!$item->isRemiseChanged()) { $this->computePrixUserByMarque($item, $userId); }
					}

					$this->computePrixCommandByProductQte($item, $facture);

					if (!empty($facture->code_reduction) && isset($facture->code_reduction['PRODUITREF']) && !empty($facture->code_reduction['PRODUITREF'])) {
						$facture->checkCodeReductionProduct($item->item_reference, $item->item_qte);
					}

					$poidsCurrent = $item->getPoidsTotal();
					if ($poidsCurrent > 0) { $facture->total_poids += $poidsCurrent ;
					} else { $facture->isAncienPoids = true;  }

					if ($item->isFrancoDenied()) { $facture->isFrancoDenied = true; }

					$facture->total_HT_HR += $item->getPrixTotalHT(true);
				}
			}
		}

		$this->computePrixCommandByTotalHT($facture);
		$this->computePrixCommandByAll($facture);
			
		if (isset($user) && !empty($user)) {
			$this->computePrixUserByDateInscription($facture, $user['dateinsc']);

			$this->computePrixUserByUser($facture, $user['id']);

			$this->computePrixUserByIsFirstCommand($facture, $user['id']);
		}
			
		$this->computePrixCodeReduction($facture);
	}

	public function computeItemsPromosCaddyType($caddyItems, $user) {
		foreach ($caddyItems AS $item) {
			if (!$item->isPromo()) {
				$promoProduct = new PromoProduct();
				$promoUser = new PromoUser();

				$myPromo = $promoProduct->getRemiseByProductReference($item->reference);
				if ($myPromo) { $item->setRemise($myPromo['REMISEEURO'], $myPromo['REMISEPOUR']); }
 
				if (!$item->isRemiseChanged()) { 
					$myPromo = $promoProduct->getRemiseByProductBrend($item->idBrend);
					if ($myPromo) { $item->setRemise($myPromo['REMISEEURO'], $myPromo['REMISEPOUR']); }
				}

				if (!$item->isRemiseChanged()) {
					$myPromo = $promoProduct->getRemiseByProductCategory($item->idcategory);
					if ($myPromo) { $item->setRemise($myPromo['REMISEEURO'], $myPromo['REMISEPOUR']); }
				}
				if (!$item->isRemiseChanged()) {
					$myPromo = $promoProduct->getRemisesByProductQte($item->reference, $item->qte);
					if ($myPromo) {
						foreach ($caddyItems AS $line) {
							foreach ($myPromo AS $promo) {
								if (($line->reference == $promo['CHILDREFBUY']) &&
								($line->qte >= $promo['CHILDREFBUYNB']) ) {
									$item->setRemise($promo['REMISEEURO'], $promo['REMISEPOUR']);
								}
							}
						}
					}
				}
				if (!$item->isRemiseChanged()) {
					$myPromo = $promoProduct->getRemiseByProductDateBetween($item->promo_date);
					if ($myPromo) { $item->setRemise($myPromo['REMISEEURO'], $myPromo['REMISEPOUR']); }
				}
				if (isset($user) && !empty($user)) {
					$userId = $user['id'];
					$codeIntern = $user['cintern'];

					if (!empty($codeIntern)) {
						$myPromo = $promoUser->getRemiseByCodeInternMarque($item->idBrend, $codeIntern);
						if ($myPromo) { $item->setRemise($myPromo['REMISEEURO'], $myPromo['REMISEPOUR']); }
					}
					if (!$item->isRemiseChanged()) {
						$myPromo = $promoUser->getRemiseByMarque($item->idBrend, $userId);
						if ($myPromo) { $item->setRemise($myPromo['REMISEEURO'], $myPromo['REMISEPOUR']); }
					}
				}
			}
		}
	}
}
?>PKVH[�ԉ���Item.phpnu&1i�<?php 
class Item {
    var $idProduit;
    var $idChild;
    var $qteChild;
    var $nom;
    var $descshort;
    var $navnom;
    var $url;
    var $designation;
    var $stock = 1;
    var $isAccessoire = 'N'; 
    var $selectedOption = "";
     
    function Item() { }
    
    function getItemInfo($idChild, $qteChild, $isAccessoire, $selectedOption) {
    	$sql = "
			SELECT p.NOM NOM, p.NAVNOM NAVNOM, p.DESCRIPTIONSHORT DESCSHORT, p.ID IDPRODUCT, pic.URL URL, pc.DESIGNATION DESIGNATION, p.STOCK STOCK
			FROM productchild pc
			LEFT JOIN product p ON p.ID = pc.IDPRODUCT
			LEFT JOIN picture pic ON pic.IDPRODUCT = p.ID 
			WHERE pc.ID = ".$idChild."
			AND p.isACTIVE = 0
			AND pic.POSITION = 1
			";
			$productChild = new ProductChild();
			$result = $productChild->getAdapter()->fetchRow($sql);
			 
			$this->idChild = $idChild;
			$this->qteChild = $qteChild;
			$this->idProduit = $result['IDPRODUCT'];
			$this->nom = $result['NOM'];
			$this->descshort = $result['DESCSHORT'];
			$this->navnom = $result['NAVNOM'];
			$this->url = $result['URL'];
			$this->designation = $result['DESIGNATION'];
			$this->stock = $result['STOCK'];
			$this->isAccessoire = $isAccessoire;
			$this->selectedOption = $selectedOption;
    }
    
    public function toString() {
    	return $this->nom." - ".$this->idChild." : ".$this->qteChild."<br>";
    }
    
    public function isItemAccessoire() {
    	if ($this->isAccessoire == "Y") { return true; }
    	return false;
    }
}

?>
PKVH[� P'1.1.UploadHandler.phpnu&1i�<?php

/**
 * Do not use or reference this directly from your client-side code.
 * Instead, this should be required via the endpoint.php or endpoint-cors.php
 * file(s).
 */

class UploadHandler {

    public $allowedExtensions = array();
    public $sizeLimit = null;
    public $inputName = 'qqfile';
    public $chunksFolder = 'chunks';

    public $chunksCleanupProbability = 0.001; // Once in 1000 requests on avg
    public $chunksExpireIn = 604800; // One week

    protected $uploadName;

    /**
     * Get the original filename
     */
    public function getName(){
        if (isset($_REQUEST['qqfilename']))
            return $_REQUEST['qqfilename'];

        if (isset($_FILES[$this->inputName]))
            return $_FILES[$this->inputName]['name'];
    }

    public function getInitialFiles() {
        $initialFiles = array();

        for ($i = 0; $i < 5000; $i++) {
            array_push($initialFiles, array("name" => "name" + $i, uuid => "uuid" + $i, thumbnailUrl => "/test/dev/handlers/vendor/fineuploader/php-traditional-server/fu.png"));
        }

        return $initialFiles;
    }

    /**
     * Get the name of the uploaded file
     */
    public function getUploadName(){
        return $this->uploadName;
    }

    public function combineChunks($uploadDirectory, $name = null) {
        $uuid = $_POST['qquuid'];
        if ($name === null){
            $name = $this->getName();
        }
        $targetFolder = $this->chunksFolder.DIRECTORY_SEPARATOR.$uuid;
        $totalParts = isset($_REQUEST['qqtotalparts']) ? (int)$_REQUEST['qqtotalparts'] : 1;

        $targetPath = join(DIRECTORY_SEPARATOR, array($uploadDirectory, $uuid, $name));
        $this->uploadName = $name;

        if (!file_exists($targetPath)){
            mkdir(dirname($targetPath));
        }
        $target = fopen($targetPath, 'wb');

        for ($i=0; $i<$totalParts; $i++){
            $chunk = fopen($targetFolder.DIRECTORY_SEPARATOR.$i, "rb");
            stream_copy_to_stream($chunk, $target);
            fclose($chunk);
        }

        // Success
        fclose($target);

        for ($i=0; $i<$totalParts; $i++){
            unlink($targetFolder.DIRECTORY_SEPARATOR.$i);
        }

        rmdir($targetFolder);

        if (!is_null($this->sizeLimit) && filesize($targetPath) > $this->sizeLimit) {
            unlink($targetPath);
            http_response_code(413);
            return array("success" => false, "uuid" => $uuid, "preventRetry" => true);
        }

        return array("success" => true, "uuid" => $uuid);
    }

    /**
     * Process the upload.
     * @param string $uploadDirectory Target directory.
     * @param string $name Overwrites the name of the file.
     */
    public function handleUpload($uploadDirectory, $name = null){

        if (is_writable($this->chunksFolder) &&
            1 == mt_rand(1, 1/$this->chunksCleanupProbability)){

            // Run garbage collection
            $this->cleanupChunks();
        }

        // Check that the max upload size specified in class configuration does not
        // exceed size allowed by server config
        if ($this->toBytes(ini_get('post_max_size')) < $this->sizeLimit ||
            $this->toBytes(ini_get('upload_max_filesize')) < $this->sizeLimit){
            $neededRequestSize = max(1, $this->sizeLimit / 1024 / 1024) . 'M';
            return array('error'=>"Server error. Increase post_max_size and upload_max_filesize to ".$neededRequestSize);
        }

        if ($this->isInaccessible($uploadDirectory)){
            return array('error' => "Server error. Uploads directory isn't writable");
        }

        $type = $_SERVER['CONTENT_TYPE'];
        if (isset($_SERVER['HTTP_CONTENT_TYPE'])) {
            $type = $_SERVER['HTTP_CONTENT_TYPE'];
        }

        if(!isset($type)) {
            return array('error' => "No files were uploaded.");
        } else if (strpos(strtolower($type), 'multipart/') !== 0){
            return array('error' => "Server error. Not a multipart request. Please set forceMultipart to default value (true).");
        }

        // Get size and name
        $file = $_FILES[$this->inputName];
        $size = $file['size'];
        if (isset($_REQUEST['qqtotalfilesize'])) {
            $size = $_REQUEST['qqtotalfilesize'];
        }

        if ($name === null){
            $name = $this->getName();
        }

        // Validate name
        if ($name === null || $name === ''){
            return array('error' => 'File name empty.');
        }

        // Validate file size
        if ($size == 0){
            return array('error' => 'File is empty.');
        }

        if (!is_null($this->sizeLimit) && $size > $this->sizeLimit) {
            return array('error' => 'File is too large.', 'preventRetry' => true);
        }

        // Validate file extension
        $pathinfo = pathinfo($name);
        $ext = isset($pathinfo['extension']) ? $pathinfo['extension'] : '';

        if($this->allowedExtensions && !in_array(strtolower($ext), array_map("strtolower", $this->allowedExtensions))){
            $these = implode(', ', $this->allowedExtensions);
            return array('error' => 'File has an invalid extension, it should be one of '. $these . '.');
        }

        // Save a chunk
        $totalParts = isset($_REQUEST['qqtotalparts']) ? (int)$_REQUEST['qqtotalparts'] : 1;

        $uuid = $_REQUEST['qquuid'];
        if ($totalParts > 1){
        # chunked upload

            $chunksFolder = $this->chunksFolder;
            $partIndex = (int)$_REQUEST['qqpartindex'];

            if (!is_writable($chunksFolder) && !is_executable($uploadDirectory)){
                return array('error' => "Server error. Chunks directory isn't writable or executable.");
            }

            $targetFolder = $this->chunksFolder.DIRECTORY_SEPARATOR.$uuid;

            if (!file_exists($targetFolder)){
                mkdir($targetFolder);
            }

            $target = $targetFolder.'/'.$partIndex;
            $success = move_uploaded_file($_FILES[$this->inputName]['tmp_name'], $target);

            return array("success" => $success, "uuid" => $uuid, "uploadName" => $name);

        }
        else {
        # non-chunked upload

            $target = join(DIRECTORY_SEPARATOR, array($uploadDirectory, $uuid, $name));
	
            if ($target){
                $this->uploadName = basename($target);

                if (!is_dir(dirname($target))){
                    mkdir(dirname($target));
                }
                if (move_uploaded_file($file['tmp_name'], $target)){
                    return array('success'=> true, "uuid" => $uuid, "uploadName" => $name);
                }
            }

            return array('error'=> 'Could not save uploaded file.' .
                'The upload was cancelled, or server error encountered : '.$target. ' Name : '.$name);
        }
    }

    /**
     * Process a delete.
     * @param string $uploadDirectory Target directory.
     * @params string $name Overwrites the name of the file.
     *
     */
    public function handleDelete($uploadDirectory, $name=null)
    {
        if ($this->isInaccessible($uploadDirectory)) {
            return array('error' => "Server error. Uploads directory isn't writable" . ((!$this->isWindows()) ? " or executable." : "."));
        }

        $targetFolder = $uploadDirectory;
        $url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
        $tokens = explode('/', $url);
        $uuid = $tokens[sizeof($tokens)-1];

        $target = join(DIRECTORY_SEPARATOR, array($targetFolder, $uuid));

        if (is_dir($target)){
            $this->removeDir($target);
            return array("success" => true, "uuid" => $uuid);
        } else {
            return array("success" => false,
                "error" => "File not found! Unable to delete.".$url,
                "path" => $uuid
            );
        }

    }

    /**
     * Returns a path to use with this upload. Check that the name does not exist,
     * and appends a suffix otherwise.
     * @param string $uploadDirectory Target directory
     * @param string $filename The name of the file to use.
     */
    protected function getUniqueTargetPath($uploadDirectory, $filename)
    {
        // Allow only one process at the time to get a unique file name, otherwise
        // if multiple people would upload a file with the same name at the same time
        // only the latest would be saved.

        if (function_exists('sem_acquire')){
            $lock = sem_get(ftok(__FILE__, 'u'));
            sem_acquire($lock);
        }

        $pathinfo = pathinfo($filename);
        $base = $pathinfo['filename'];
        $ext = isset($pathinfo['extension']) ? $pathinfo['extension'] : '';
        $ext = $ext == '' ? $ext : '.' . $ext;

        $unique = $base;
        $suffix = 0;

        // Get unique file name for the file, by appending random suffix.

        while (file_exists($uploadDirectory . DIRECTORY_SEPARATOR . $unique . $ext)){
            $suffix += rand(1, 999);
            $unique = $base.'-'.$suffix;
        }

        $result =  $uploadDirectory . DIRECTORY_SEPARATOR . $unique . $ext;

        // Create an empty target file
        if (!touch($result)){
            // Failed
            $result = false;
        }

        if (function_exists('sem_acquire')){
            sem_release($lock);
        }

        return $result;
    }

    /**
     * Deletes all file parts in the chunks folder for files uploaded
     * more than chunksExpireIn seconds ago
     */
    protected function cleanupChunks(){
        foreach (scandir($this->chunksFolder) as $item){
            if ($item == "." || $item == "..")
                continue;

            $path = $this->chunksFolder.DIRECTORY_SEPARATOR.$item;

            if (!is_dir($path))
                continue;

            if (time() - filemtime($path) > $this->chunksExpireIn){
                $this->removeDir($path);
            }
        }
    }

    /**
     * Removes a directory and all files contained inside
     * @param string $dir
     */
    protected function removeDir($dir){
        foreach (scandir($dir) as $item){
            if ($item == "." || $item == "..")
                continue;

            if (is_dir($item)){
                $this->removeDir($item);
            } else {
                unlink(join(DIRECTORY_SEPARATOR, array($dir, $item)));
            }

        }
        rmdir($dir);
    }

    /**
     * Converts a given size with units to bytes.
     * @param string $str
     */
    protected function toBytes($str){
        $val = trim($str);
        $last = strtolower($str[strlen($str)-1]);
        switch($last) {
            case 'g': $val *= 1024;
            case 'm': $val *= 1024;
            case 'k': $val *= 1024;
        }
        return $val;
    }

    /**
     * Determines whether a directory can be accessed.
     *
     * is_executable() is not reliable on Windows prior PHP 5.0.0
     *  (http://www.php.net/manual/en/function.is-executable.php)
     * The following tests if the current OS is Windows and if so, merely
     * checks if the folder is writable;
     * otherwise, it checks additionally for executable status (like before).
     *
     * @param string $directory The target directory to test access
     */
    protected function isInaccessible($directory) {
        $isWin = $this->isWindows();
        $folderInaccessible = ($isWin) ? !is_writable($directory) : ( !is_writable($directory) && !is_executable($directory) );
        return $folderInaccessible;
    }

    /**
     * Determines is the OS is Windows or not
     *
     * @return boolean
     */

    protected function isWindows() {
    	$isWin = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
    	return $isWin;
    }

}
PKVH[�{z��FactureLine.phpnu&1i�<?php

class FactureLine {
	var $is_fidelite = false;
	var $fidelite_nom;
	var $fidelite_nbpoint;    
	var $fidelite_id;    
    
	var $product_id;
	var $product_nom;
	var $product_descshort;
	var $product_navnom;
	var $product_navnom_urlparents;
	var $product_url;
	var $product_isPromo;
	var $product_brend_id;
	var $product_isBrend;
	var $product_category_id;
	var $product_promo_date;

	var $item_id;
	var $item_reference;
	var $item_qte;
	var $item_qte_min;
	var $item_designation;
	var $item_stock;
	var $item_poids;
	var $item_isAccessoire;
	var $item_isPromo;
	var $item_isDevis;
	var $item_isFrancoDenied;
	var $item_selectedOption = "";
	var $item_optionsByList;
	var $item_nbpointfidelite;

	var $item_prix;
	var $remise_euro = 0;
	var $remise_pour = 0;

	//Remise sur un certain nombre d'articles
	var $remise_items;
	
	//Si c'est une ligne du caddy type
	var $isCaddyType = false;
	var $caddytype_id = 0;
	var $caddytype_isActif;
	var $caddytype_qte_total = 0;


	function FactureLine() { $this->remise_items = array(); }

	public function isRemiseChanged() {
		if ($this->remise_euro > 0 || $this->remise_pour > 0) { return true; }
		return false;
	}
	
	public function getPrixRemise() {
		if ($this->remise_euro > 0) {
			return sprintf("%.2f", $this->remise_euro);
		} else if ($this->remise_pour > 0) {
			return sprintf("%.2f",($this->item_prix * $this->remise_pour) / 100);
		}
		return 0;
	}

	public function getPrixAfterRemise() {
		if ($this->remise_euro > 0) {
			return sprintf("%.2f",$this->item_prix - $this->remise_euro);
		} else if ($this->remise_pour > 0) {
			return sprintf("%.2f",$this->item_prix - (($this->item_prix * $this->remise_pour) / 100));
		}
		return sprintf("%.2f",$this->item_prix);
	}
	public function getPrixAfterRemiseOfItems() {
		if (!empty($this->remise_items)) {
			if ($this->remise_items['REMISE_EURO'] > 0) {
				return sprintf("%.2f",$this->item_prix - $this->remise_items['REMISE_EURO']);
			} else if ($this->remise_items['REMISE_POUR'] > 0) {
				return sprintf("%.2f",$this->item_prix - (($this->item_prix * $this->remise_items['REMISE_POUR']) / 100));
			}
		}
		return sprintf("%.2f",$this->item_prix);
	}

	public function getPrixTotalHT($isRemise) {
		$result = 0;
		if ($isRemise) {
			 //Pour les autres remises
			$prixAfter = $this->getPrixAfterRemise();
			$prixTotalAfter = $prixAfter * $this->item_qte;
			
			$result = $prixTotalAfter;
			//Pour la promotion X selon Y avec des qtes
			if (!empty($this->remise_items)) {
				$prixAfterSome = $this->getPrixAfterRemiseOfItems(); 
				if ($this->item_qte >= $this->remise_items['NB']) {
					$prixTotalAfterSome = ($prixAfterSome * $this->remise_items['NB']) + (($this->item_qte - $this->remise_items['NB']) * $this->item_prix);
				} 
				
				if ($prixTotalAfterSome < $prixTotalAfter) { $result = $prixTotalAfterSome; }
			} 
			return sprintf("%.2f",$result); 
		}
		return sprintf("%.2f",$this->item_prix * $this->item_qte);
	}

	public function checkPrixPromo() {
		if ($this->isRemiseChanged()) { 
			$this->product_isPromo = 0;
			$this->item_isPromo = 0; 
		}  else {
			$this->product_isPromo = 1;
			$this->item_isPromo = 1;
		}
	}

	public function getPoidsTotal() {
		return ((int)$this->item_poids) * $this->item_qte;
	}

	public function setLineInfo($row, $qte, $isAcc) {
		$this->product_id = $row['IDPRODUCT'];
		$this->product_nom = $row['NOM'];
		$this->product_descshort = $row['DESCSHORT'];
		$this->product_navnom = $row['NAVNOM'];
		$this->product_navnom_urlparents = $row['NAVNOM_URLPARENTS'];
		$this->product_url = $row['URL'];
		$this->product_isPromo = $row['isPROMO'];
		$this->product_brend_id = $row['IDBREND'];
		$this->product_isBrend = $row['isSHOWBREND'];
		$this->product_category_id = $row['IDCATEGORY'];
		$this->product_promo_date = $row['DATEPROMO'];
			
		$this->item_id = $row['IDCHILD'];
		$this->item_reference = $row['REFERENCE'];
		$this->item_designation = $row['DESIGNATION'];
		$this->item_stock  = $row['STOCK'];
		$this->item_isPromo  = $row['isPROMOCHILD'];
		$this->item_isDevis  = $row['isDEVIS'];
		$this->item_poids  = $row['POIDS'];
		$this->item_isFrancoDenied  = $row['isFRANCODENIED'];
		$this->item_qte_min  = $row['QUANTITYMIN'];
			
		/*Recuperation du prix degressif*/
		$productChildQte = new ProductChildQte();
		$currentPrice = $productChildQte->getCurrentPrice($row['IDCHILD'], $qte, $row['PRIX']);
		$this->item_prix = sprintf("%.2f",$currentPrice);
		//$this->item_prix = sprintf("%.2f",$row['PRIX']);
			
		$this->item_qte = $qte;
		$this->item_isAccessoire = $isAcc;
		
		$optionList = new OptionList();
		$this->item_optionsByList = $optionList->getByIdProduct($row['IDPRODUCT']);
		$this->item_nbpointfidelite  = $row['POINTFIDELITE'];
	}

	public function toString() {
		return $this->product_nom." - ".$this->item_id." : ".$this->item_qte."<br>";
	}

	public function isAccessoire() {
		if ($this->isAccessoire == "Y") { return true; }
		return false;
	}
	public function isPromo() {
		if ($this->item_isPromo == 0) { return true; }
		return false;
	}
	public function setPromo($value) {
		if ($value) {$this->item_isPromo = 0; } 
		else {$this->item_isPromo = 1;} 
	}
	public function setPromoCaddyType($value) {
		if ($value) {
			$this->item_isPromo = 0; 
			$this->isCaddyType = true;
			$this->item_isDevis = 1; 
		}  else {
			$this->isCaddyType = false;
			$this->caddytype_id = 0; 
		} 
	}
	 			
	public function isSurDevis() {
		if ($this->item_isDevis == 0) { return true; }
		return false;
	}
	public function isBrend() {
		if ($this->product_isBrend == 0) { return true; }
		return false;
	}
	public function isFrancoDenied() {
		if ($this->item_isFrancoDenied == 0) { return true; }
		return false;
	}
	
	public function isCaddyTypeActif() {
		if ($this->isCaddyType && $this->caddytype_isActif == 'Y') { return  true;}
		return false;
	}
    
	public function setFideliteGift($row) {
        $this->is_fidelite = true;
		$this->fidelite_nom = $row->nom;
		$this->fidelite_nbpoint = $row->nbpoint;
		$this->fidelite_id = $row->idFidelite;
    }
	public function isFideliteGift() {
		return $this->is_fidelite;
	}
}

?>
PKVH[�r���ItemFidelite.phpnu&1i�<?php 
class ItemFidelite { 
    var $idFidelite; 
    var $nom;  
    var $nbpoint; 
     
    function ItemFidelite() { }
    
    function getItemInfo($idfidelite) {
        $carteFidelite = new CarteFidelite();
        $result = $carteFidelite->getInfosEnableById($idfidelite);
        if (isset($result) && !empty($result)) {
            $this->nom = $result['TITRE'];
		    $this->nbpoint = $result['POINTFIDELITE'];
            $this->idFidelite = $result['ID'];
        }
    } 
}

?>
PKVH[��uuItemOptionList.phpnu&1i�<?php
class ItemOptionList { 
	var $id;
	var $name;
	var $values; 
	var $valuesString;

	function ItemOptionList() {
		$this->name = '';
		$this->values = array();
	} 
	function init($option) {
		if (!empty($option)) {  
			$valeurs = explode("::", $option['VALUE']); 
		 	$this->id = $option['ID'];
		 	$this->name = $option['NAME'];
		 	$this->valuesString = $option['VALUE'];
		 	foreach ($valeurs as $opt) {  array_push($this->values, $opt); } 
		} 
	} 
	function valuesHTML() {
		$result = '';
		if (!empty($this->values)) {  
		 	foreach ($this->values as $opt) { $result .= $opt.'<br/>';} 
		} 
		return $result;
	} 
}

?>PKVH[>�B/RRItemCaddyType.phpnu&1i�PKVH[_a���Facture.phpnu&1i�PKVH[�����N!CaddyFidelite.phpnu&1i�PKVH[�9��	p$Caddy.phpnu&1i�PKVH[tS�U�4�4�7PromoCalculator.phpnu&1i�PKVH[�ԉ���mItem.phpnu&1i�PKVH[� P'1.1.sUploadHandler.phpnu&1i�PKVH[�{z����FactureLine.phpnu&1i�PKVH[�r�����ItemFidelite.phpnu&1i�PKVH[��uu�ItemOptionList.phpnu&1i�PK

��