Current File : /home/karenpetzb/application/models/utils/FactureLine.php |
<?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;
}
}
?>