<?php
/* **
 * @application PhpMyShopping
 * @part        Admin Boutique
 * @file        class.order.php
 * @path        ./admin/include/
 * @author      Stephane DINE <stephane@phpmyshopping.org>
 * @site        http://www.phpmyshopping.org
 * @license     http://www.php.net/license/3_0.txt  PHP License 3.0
 *
 * PHP version 5
 *
 * Classe Order
 *
 * Gestion des commandes clients
 */

require_once 'class.lib.php';

class Order extends Lib
{
	private $order_status = array('CA' => 'Commande en attente de paiement',
				  				  'CS' => 'Commande en attente',
								  'CC' => 'Commande en cours de pr&eacute;paration',
								  'CV' => 'Commande valid&eacute;e',
							 	  'CT' => 'Commande en cours de livraison',
								  'CL' => 'Commande livr&eacute;e');
	public $orderTotal;
	public $orderCost;
	public $orderCreateDate;
	public $orderTaxTotal;




	/** *****************************************************************************************************************************
	 * Constructeur
	 *
	 * @access public
	 */
	public function __construct($nbMax = 5)
	{
		$this->nbmax        = $nbMax;
		$this->urlRewriting = false;
	}




    /** *****************************************************************************************************************************
     * Methode get_order_status
     *
     * @desc   Retourne le ou les types de status pour une commande
     * @param  $type       string Code du type de status demande
     * @param  $return_all bool   Si true, on retourne tous les types de status, sinon celui demande
     * @return string / array
     * @access public
     */
    public function get_order_status($status = 'CA', $return_all = false)
    {
        if ($return_all == false) {
            $type_status = $this->order_status[$status];
        } else {
            $type_status = $this->order_status;
        }
        
        return $type_status;
    }




	/** *****************************************************************************************************************************
	 * Methode orderList
	 *
	 * @desc   Liste des commandes pour la page historique_commande.php
	 * @param  int $ID_Customer Identifiant du client
	 * @return array / false
	 * @access public
	 */
	public function orderList($ID_Customer)
	{
        $this->log(__FILE__, array('methode' => __METHOD__, 'variable' => array('$ID_Customer' => $ID_Customer)));

		/**
		 * Recuperation des commandes
		 */
		$sql = 'SELECT o.ID_Orders AS ID_Orders,
					   SUM((CalculPrixTTC(ProductPrice, TaxValue) * Quantity)) AS TotalPriceOrder,
					   BillNumber, o.Status AS OrdersStatus, Cost, o.Status AS StatusType,
					   DATE_FORMAT(FROM_UNIXTIME(CreationDate), "%d/%m/%Y") AS CreationDate
				FROM OrdersDetail AS d
				LEFT JOIN Orders AS o ON o.ID_Orders = d.ID_Orders
				WHERE o.ID_Customer = '.$ID_Customer.'
				GROUP BY CreationDate DESC';

		$query = $this->query($sql);

		while ($result = @mysql_fetch_array($query)) {
            list($day, $month, $year) = split('/', $result['CreationDate']);
            $date_fr = $day.' '.$this->moisFrancais($month).' '.$year;

			$data[] = array('ID_Orders'    => $result['ID_Orders'],
							'Date'         => $date_fr,
							'BillNumber'   => $result['BillNumber'],
							'Amount'       => number_format(($result['TotalPriceOrder'] + $result['Cost']), 2, ',', ' '),
							'Status'       => $result['OrdersStatus'],
							'Cost'         => $result['Cost'],
							'DetailStatus' => $this->get_order_status($result['StatusType']));
		}

		if (count($data) > 0) {
			return $data;
		} else {
			return false;
		}
	}




	/** *****************************************************************************************************************************
	 * Methode orderDetail
	 *
	 * @desc   Detail d'une commande pour la page historique_commande.php
	 * @param  int $ID_Customer Identifiant du client
	 * @param  int $ID_Orders   Identifiant de la commande
	 * @return array / false
	 * @access public
	 */
	public function orderDetail($ID_Customer, $ID_Orders)
	{
        $this->log(__FILE__, array('methode' => __METHOD__, 'variable' => array('$ID_Customer' => $ID_Customer, '$ID_Orders' => $ID_Orders)));

		/**
		 * Recuperation des donnees de la commande
		 */
		$sql = 'SELECT Reference, ProductName, CalculPrixTTC(ProductPrice, TaxValue) AS PriceAndTax,
					   Quantity, (CalculPrixTTC(ProductPrice, TaxValue) * Quantity) AS PriceAndTaxLine,
					   (ROUND(((ProductPrice / 100) * TaxValue), 2) * Quantity) AS TaxLine
				FROM OrdersDetail AS o
				RIGHT JOIN Orders AS d ON d.ID_Orders = o.ID_Orders
				WHERE d.ID_Customer = '.$ID_Customer.'
				AND o.ID_Orders = '.$ID_Orders.'
				ORDER BY ID_OrdersDetail';

		$query = $this->query($sql);

		while ($result = @mysql_fetch_array($query)) {
			$totalTax[] = $result['TaxLine'];
			$data[] = array('Reference'   => $result['Reference'],
							'ProductName' => $result['ProductName'],
							'Price'       => $result['PriceAndTax'],
							'Quantity'    => $result['Quantity'],
							'PriceLine'   => $result['PriceAndTaxLine']);
		}

		/**
		 * Recuperation du montant de la commande et des frais d'envoi
		 */
		$sqlSum = 'SELECT SUM(CalculPrixTTC(ProductPrice, TaxValue) * Quantity) AS OrderSum,
						  DATE_FORMAT(FROM_UNIXTIME(CreationDate), "%d/%m/%Y") AS CreationDate, Cost
				   FROM OrdersDetail
				   RIGHT JOIN Orders ON Orders.ID_Orders = OrdersDetail.ID_Orders
				   WHERE Orders.ID_Customer = '.$ID_Customer.'
				   AND OrdersDetail.ID_Orders = '.$ID_Orders;

		$querySum = $this->query($sqlSum);
		$resultSum = @mysql_fetch_array($querySum);

		$this->orderTotal      = $resultSum['OrderSum'];
		$this->orderTaxTotal   = number_format(array_sum($totalTax), 2, ',', '');
		$this->orderCost       = $resultSum['Cost'];

        list($day, $month, $year) = split('/', $resultSum['CreationDate']);
		$this->orderCreateDate = $day.' '.$this->moisFrancais($month).' '.$year;

		if (count($data) > 0) {
			return $data;
		} else {
			return false;
		}
	}




	/** *****************************************************************************************************************************
	 * Methode orderListAdmin
	 *
	 * @desc   Liste des commandes (panel d'administration)
	 * @param  array $data Donnees retournees a la methode
	 * @return string
	 * @access public
	 */
	public function orderListAdmin($data)
	{
        $this->log(__FILE__, array('methode' => __METHOD__));

		/**
		 * Recuperation des commandes
		 */
		$sql = 'SELECT od.ID_Orders AS ID_Orders, od.ID_Customer AS ID_Customer,
					   SUM((CalculPrixTTC(ProductPrice, TaxValue) * Quantity)) AS TotalPriceOrder,
					   GenderName, FirstName, LastName, BillNumber,
					   DATE_FORMAT(FROM_UNIXTIME(CreationDate), "%d/%m/%Y %H:%i") AS CreationDate,
					   od.Status AS OrdersStatus, pt.PaymentCode AS OrderPaymentCode, PaymentType
				FROM OrdersDetail AS ot
				LEFT JOIN Orders AS od ON od.ID_Orders = ot.ID_Orders
				LEFT JOIN Customer AS cu ON cu.ID_Customer = od.ID_Customer
				LEFT JOIN Gender AS ge ON ge.ID_Gender = cu.ID_Gender
				LEFT JOIN PaymentType AS pt ON pt.ID_PaymentType = od.ID_PaymentType
				WHERE od.Status = "'.$data['orderStatus'].'"
				GROUP BY CreationDate
				ORDER BY '.$data['field'].' '.$data['order'].'
				LIMIT '.$data['debut'].', '.$this->nbmax;
		$query = $this->query($sql);
		$nblines = mysql_num_rows($query);

		/**
		 * Liste des differents status possible pour une commande
		 */
        foreach ($this->get_order_status('', true) as $k => $v) {
            if ($k != $data['orderStatus']) {
                $selected = '';
            } else {
                $selected = 'selected';
            }

            $status_list .= '<option value="'.$k.'"'.$selected.'>'.$v.'</option>';
        }

		$orderStatusList = '
		<form action="" method="POST">
		  <input type="hidden" name="C1" value="CL" />
		  <input type="hidden" name="C2" value="CO" />
		  <input type="hidden" name="C3" value="list" />
		  <select name="orderStatus" size="1" onChange="submit()">'.$status_list.'</select>
          &nbsp;<b>::</b>&nbsp;<input type="submit" name="valieOrderStatus" value="Afficher" />
		</form>';

		$arrow_up   = '<img src="images/arrow_up.jpg" title="up" alt="up" border="0" />';
		$arrow_down = '<img src="images/arrow_down.jpg" title="down" alt="down" border="0" />';


		/**
		 * Affichage des commandes
		 */
		$list = '
		<div class="heading">Liste des commandes '.$orderStatusList.'</div>
		<div id="list">
		  <table class="list">
			<tr>
			  <th align="center" width="1%">&nbsp;</th>
			  <th align="left" width="40%">Client</th>
			  <th align="right" nowrap="nowrap" width="19%">Montant total</th>
			  <th align="center" width="1%">Paiement</th>
			  <th align="center" nowrap="nowrap" width="19%">Date</th>
			  <th align="center" nowrap="nowrap" width="20%">Num&eacute;ro</th>
			<th align="center" width="1%">&nbsp;</th>
		  </tr>';

		while ($result = mysql_fetch_array($query)) {
			$list .= '
			<tr class="row2" onmouseover="this.className=\'highlight\'" onmouseout="this.className=\'row2\'">
			  <td align="center"><a href="?C1=CL&C2=CO&C3=edit&IDO='.$result['ID_Orders'].'"><img src="./images/view_cmd.png" border="0" alt="View" "Voir le detail de la commande" /></a></td>
			  <td nowrap="nowrap" align="left">'.$result['GenderName'].$result['FirstName'].'&nbsp;'.$result['LastName'].'</td>
			  <td nowrap="nowrap" align="right">'.$result['TotalPriceOrder'].'&nbsp;&euro;</td>
			  <td nowrap="nowrap" align="center"><img src="./images/'.$result['OrderPaymentCode'].'.png" alt="'.$result['OrderPaymentCode'].'" title="'.$result['PaymentType'].'" /></td>
			  <td nowrap="nowrap" align="center">'.$result['CreationDate'].'</td>
			  <td align="center">'.$result['BillNumber'].'</td>
			  <td class="center" width="1%"><a href="?C1=CL&C2=CO&C3=delete_confirm&IDO='.$result['ID_Orders'].'&debut='.$data['debut'].'&IDC='.$result['ID_Customer'].'&field='.$data['field'].'&order='.$data['order'].'&orderStatus='.$data['orderStatus'].'"><img src="./images/delete.png" alt="Effacer" title="Effacer" /></a></td>
			</tr>';
		}


		$sqlNbLines = 'SELECT COUNT(ID_Orders) FROM Orders WHERE Status = "'.$data['orderStatus'].'"';
		$criteres   = '&C1=CL&C2=CO&C3=list&field='.$data['field'].'&order='.$data['order'].'&orderStatus='.$data['orderStatus'];


		$list .= '
		<tr>
		  <td colspan="7">
		  '.$this->barreNav('', '', $criteres, $data['debut'], 20, ' style="font-size: 14px;"', false, $sqlNbLines, './images', ' style="font-size: 14px;"').'
		  </td>
		</tr>
		</table>';

		return $list;
	}




	/** *****************************************************************************************************************************
	 * Methode orderView
	 *
	 * @desc   Affichage du detail d'une commande
	 * @param  int $ID_Orders Identifiant de la commande
	 * @return string
	 * @access public
	 */
	public function orderView($ID_Orders)
	{
        $this->log(__FILE__, array('methode' => __METHOD__, 'variable' => array('$ID_Orders' => $ID_Orders)));

		/**
		 * Affichage des commandes
		 */
		$order = '<br />

		<table cellspacing="1" cellpadding="2" border="0" bgcolor="#D5D5D5" width="75%" style="margin-bottom: 0px" align="center">
		  <tr bgcolor="#F1F3F5">
			<td colspan="7" align="left"><div class="heading">Edition commande</div></td>
		  </tr>';

		/**
		 * Recuperation des donnees sur le client
		 */
		$sqlCustomer = 'SELECT cu.ID_Customer, GenderName, cu.FirstName, cu.LastName, cu.Email, cu.Telephone, cu.Gsm
						FROM Customer AS cu
						LEFT JOIN Gender AS gd ON gd.ID_Gender = cu.ID_Gender
						LEFT JOIN Orders AS od ON od.ID_Customer = cu.ID_Customer
						WHERE ID_Orders = '.$ID_Orders;

		$queryCustomer = $this->query($sqlCustomer);
		$resultCustomer = mysql_fetch_array($queryCustomer);

		$order .= '
		  <tr bgcolor="#E8E5DE">
			<th colspan="7" align="left">Client</th>
		  </tr>

		  <tr bgcolor="#FFFFFF">
			<td colspan="7">

			<table width="100%">
			  <tr>
				<td align="left" valign="top">
				  <b class="blue">'.$resultCustomer['GenderName'].''.$resultCustomer['FirstName'].' '.$resultCustomer['LastName'].'</b>
				</td>
				<td align="left">
				  <b>Email</b> : '.$resultCustomer['Email'].'<br />
				  <b>T&egrave;l</b> : '.$resultCustomer['Telephone'].'<br />
				  <b>Portable</b> : '.$resultCustomer['Gsm'].'<br /><br />
				</td>
			  </tr>
			  <tr>
				<th align="left">Adresse de facturation</th>
				<th align="left">Adresse de livraison</th>
			  </tr>
			  <tr>';


		$sqlCustomerAddr = 'SELECT GenderName, ca.FirstName, ca.LastName, ca.Street, AddressType, CityName, PostCode, StateName, CountryName
							FROM CustomerAddress AS ca
							LEFT JOIN Gender AS gd  ON gd.ID_Gender = ca.ID_Gender
							LEFT JOIN City AS ci    ON ci.ID_City = ca.ID_City
							LEFT JOIN State AS st   ON st.ID_State = ci.ID_State
							LEFT JOIN Country AS co ON co.ID_Country = st.ID_Country
							WHERE ID_Customer = '.$resultCustomer['ID_Customer'].'
							ORDER BY AddressType ASC';

		$queryCustomerAddr = $this->query($sqlCustomerAddr);
		echo $this->affich_sql();

		while ($resultCustomerAddr = mysql_fetch_array($queryCustomerAddr)) {
			$order .= '
				<td align="left">
				'.$resultCustomerAddr['GenderName'].''.$resultCustomerAddr['FirstName'].' '.$resultCustomerAddr['LastName'].'<br />
				'.$resultCustomerAddr['Street'].'<br />
				'.$resultCustomerAddr['PostCode'].' - '.$resultCustomerAddr['CityName'].'<br />
				'.$resultCustomerAddr['StateName'].' - '.$resultCustomerAddr['CountryName'].'
				</td>';
		}

		$order .= '
			  </tr>
			</table>

			</td>
		  </tr>';


		/**
		 * Recuperation des donnees de la commande
		 */
		$sqlOrders = 'SELECT od.Quantity, od.ProductPrice, od.TaxValue, od.Reference, od.ProductName,
							 (CalculPrixTTC(od.ProductPrice, od.TaxValue) * od.Quantity) AS PriceAndTax,
							 oe.Status, ProductStock, ManageStock, PaymentCode, PaymentType
					  FROM OrdersDetail AS od
					  LEFT JOIN Orders AS oe ON oe.ID_Orders = od.ID_Orders
					  LEFT JOIN Product AS pr ON pr.ID_Product = od.ID_Product
                      LEFT JOIN PaymentType AS pt ON pt.ID_PaymentType = oe.ID_PaymentType
					  WHERE od.ID_Orders = '.$ID_Orders.'
					  ORDER BY ID_OrdersDetail';

		$queryOrders = $this->query($sqlOrders);

		$order .= '
		  <tr bgcolor="#E8E5DE">
			<th colspan="7" align="left">Detail de la comande</th>
		  </tr>

		  <tr bgcolor="#F3F1ED">
			<th align="center">R&eacute;f&eacute;rence</th>
			<th align="center">Article</th>
			<th align="center">Prix unitaire</th>
			<th align="center">Qte</th>
			<th align="center">En stock</th>
			<th align="center">Taxe</th>
			<th align="center">Total ligne</th>
		  </tr>';

		while ($resultOrders = mysql_fetch_array($queryOrders)) {
			if ($resultOrders['ManageStock'] == 1) {
				if ($resultOrders['ProductStock'] > 0) {
					$color = 'green';
				} else {
					$color = 'red';
				}

				$ProductStock = '<b class="'.$color.'">'.$resultOrders['ProductStock'].'</b>';
			} else {
				$ProductStock = '--';
			}

			$order .= '
			<tr bgcolor="#FFFFFF">
			  <td nowrap="nowrap" align="left">'.$resultOrders['Reference'].'</td>
			  <td nowrap="nowrap" align="left">'.$resultOrders['ProductName'].'</td>
			  <td nowrap="nowrap" align="right">'.$resultOrders['ProductPrice'].'&nbsp;&euro;</td>
			  <td nowrap="nowrap" align="center">'.$resultOrders['Quantity'].'</td>
			  <td nowrap="nowrap" align="center">'.$ProductStock.'</td>
			  <td nowrap="nowrap" align="right">'.$resultOrders['TaxValue'].'&nbsp;%</td>
			  <td nowrap="nowrap" align="right">'.$resultOrders['PriceAndTax'].'&nbsp;&euro;</td>
			</tr>';

			$resultOrdersStatus = $resultOrders['Status'];
            $paymentCode = $resultOrders['PaymentCode'];
            $paymentType = $resultOrders['PaymentType'];
		}

		if ($resultOrdersStatus != 'CL') {
			/**
			 * Liste des status possibles pour une commande
			 */
			switch ($resultOrdersStatus) {
			case 'CA':
				$orderStatus = array_slice($this->get_order_status('CA', true), 1);
				break;

			case 'CS':
				$orderStatus = array_slice($this->get_order_status('CS', true), 2);
				break;

			case 'CC':
				$orderStatus = array_slice($this->get_order_status('CC', true), 3);
				break;

			case 'CV':
				$orderStatus = array_slice($this->get_order_status('CV', true), 4);
				break;

			case 'CT':
				$orderStatus = array_slice($this->get_order_status('CT', true), 5);
				break;
			}

			foreach ($orderStatus as $k => $v) {
				if ($k != $resultOrdersStatus) {
					$orderStatusList .= '<option value="'.$k.'">'.$v.'</option>'."\n";
				}/* else {

				}*/
			}

			$orderStatusNow = $this->get_order_status($resultOrdersStatus);
			$order .= '
			  <tr bgcolor="#E8E5DE">
				<th colspan="7" align="left">Actions</th>
			  </tr>

			  <tr bgcolor="#FFFFFF">
				<td align="left" colspan="6">

				  <form action="" method="POST" name="formOrder">
					<input type="hidden" name="C1" value="CL" />
					<input type="hidden" name="C2" value="CO" />
					<input type="hidden" name="C3" value="update_status" />
					<input type="hidden" name="IDO" value="'.$ID_Orders.'" />
					<input type="hidden" name="IDC" value="'.$resultCustomer['ID_Customer'].'" />

					<br />Status actuel : <b class="green">'.$orderStatusNow.'</b><br /><br />
					Changer de status : <select name="orderStatus" size="1"><option value="XX">-- [ Choisissez un nouveau status ] --</option>
					'.$orderStatusList.'</select><br /><br />
					<input type="submit" name="modifOrderStatus" value="Valider le changement de status" /><br /><br />
				  </form>

				</td>
				<td align="center" valign="middle">
				  Paiement choisit :<br /><br /><img src="./images/'.$paymentCode.'.png" alt="'.$paymentCode.'" title="'.$paymentType.'" /><br /><br />'.$paymentType.'
                  <!--
                  <a href="../facture.php?IDC='.$resultCustomer['ID_Customer'].'&IDO='.$ID_Orders.'" target="_blank"><img src="./images/print1.jpg" title="Afficher la facture" /></a><br />
				  [ <a href="../facture.php?IDC='.$resultCustomer['ID_Customer'].'&IDO='.$ID_Orders.'" target="_blank">Afficher la facture</a> ]
                  -->
				</td>
			  </tr>';
		} else {
			$order .= '
			<tr bgcolor="#FFFFFF">
			  <td align="center" colspan="6">
				<br /><b class="green">Commande trait&eacute;e et livr&eacute;e</b><br /><br /></br />
			  </td>
			  <td align="center" valign="middle">
				<a href="../facture.php?IDC='.$resultCustomer['ID_Customer'].'&IDO='.$ID_Orders.'" target="_blank"><img src="./images/print1.jpg" title="Afficher la facture" /></a><br />
				[ <a href="../facture.php?IDC='.$resultCustomer['ID_Customer'].'&IDO='.$ID_Orders.'" target="_blank">Afficher la facture</a> ]
			  </td>
			</tr>';
		}

		$order .= '</table>';


		return $order;
	}




	/** *****************************************************************************************************************************
	 * Methode orderUpdateStatus
	 *
	 * @desc   Modification du status d'une commande et envoi d'un mail au client
	 * @param  array $data Donnees retournees a la methode
	 *                     - ID_Shop
	 *                     - ID_Customer
	 *                     - ID_Orders
	 *                     - Status
	 * @access public
	 * @return string
	 */
	public function orderUpdateStatus($data)
	{
        $v = array('$data[\'ID_Customer\']' => $data['ID_Customer'], '$data[\'ID_Orders\']' => $data['ID_Orders'], '$data[\'Status\']' => $data['Status']);
        $this->log(__FILE__, array('methode' => __METHOD__, 'variable' => $v));

		$sql = 'UPDATE Orders SET Status = "'.$data['Status'].'" WHERE ID_Customer = '.$data['ID_Customer'].' AND ID_Orders = '.$data['ID_Orders'];
		$query = $this->query($sql);

		if ($query == false) {
			return false;
			exit;
		} else {
			/**
			 * Choix du mail a envoyer
			 */
			switch ($data['Status']) {
			case 'CS':
				/**
				 * Commande en attente -> rupture de stock
				 */
				$d['Subject'] = $this->get_order_status('CS');
				$d['Text'] = 'Votre commande est actuellement en attente suite a une rupture de stock.'."\n".'Vous pouvez suivre son evolution depuis votre interface client presente sur la boutique.';
				break;

			case 'CC':
				/**
				 * Commande en cours de preparation
				 */
				$d['Subject'] = $this->get_order_status('CC');
				$d['Text'] = 'Votre commande est actuellement en cours de preparation.'."\n".'Vous pouvez suivre son evolution depuis votre interface client presente sur la boutique.';

				/**
				 * Modification du stock si Product.ManageStock = 1
				 */
				$sqlStock = 'SELECT ManageStock, ProductStock, od.ID_Product, Quantity
							 FROM Product AS pr
							 LEFT JOIN OrdersDetail AS od ON od.ID_Product = pr.ID_Product
							 WHERE ID_Orders = '.$data['ID_Orders'];

				$queryStock = $this->query($sqlStock);

				while ($resStock = mysql_fetch_array($queryStock)) {
					if (($resStock['ManageStock'] == 1) and ($resStock['ProductStock'] >= $resStock['Quantity'])) {
						$this->query('UPDATE Product SET ProductStock = (ProductStock - '.$resStock['Quantity'].') WHERE ID_Product = '.$resStock['ID_Product']);
					}
				}
				break;

			case 'CV':
				/**
				 * Commande validee
				 */
				$d['Subject'] = $this->get_order_status('CV');
				$d['Text'] = $this->get_order_status('CV');
				break;

			case 'CT':
				/**
				 * Commande en cours de livraison
				 */
				$d['Subject'] = $this->get_order_status('CT');
				$d['Text'] = $this->get_order_status('CT');
				break;

			case 'CL':
				/**
				 * Commande livree
				 */
				$d['Subject'] = $this->get_order_status('CL');
				$d['Text'] = $this->get_order_status('CL');
				break;

			default:
			}

			/**
			 * Recuperation des donnees client et envoi du mail
			 */
			$sqlCust   = 'SELECT GenderName, FirstName, Email
						  FROM Customer AS cu
						  LEFT JOIN Gender AS ge ON ge.ID_Gender = cu.ID_Gender
						  WHERE ID_Customer = '.$data['ID_Customer'];

			$queryCust = $this->query($sqlCust);
			$resulCust = mysql_fetch_array($queryCust);

			$from           = $this->getParam('mail', 'from');
			$d['Gender']    = $resulCust['GenderName'];
			$d['FirstName'] = $resulCust['FirstName'];

			$this->sendEmail(6, $resulCust['Email'], $from, $d);

			return true;
		}
	}




	/** *****************************************************************************************************************************
	 * Methode orderDelete
	 *
	 * @desc   Suppression d'une commande
	 * @param  int $ID_Customer Identifiant du client
	 * @param  int $ID_Orders   Identifiant de la commande
	 * @return bool
	 * @access public
	 */
	public function orderDelete($ID_Customer, $ID_Orders)
	{
        $this->log(__FILE__, array('methode' => __METHOD__, 'variable' => array('$ID_Customer' => $ID_Customer, '$ID_Orders' => $ID_Orders)));

		$sql = 'DELETE FROM Orders WHERE ID_Customer = '.$ID_Customer.' AND ID_Orders = '.$ID_Orders;

		if ($this->query($sql)) {
			return true;
		} else {
			return false;
		}
	}




	// /** *****************************************************************************************************************************
	 // * Methode
	 // *
	 // * @desc
	 // * @param  array $data Donnees retournees a la methode
	 // * @access public
	 // * @return string
	 // */
	// public function listOrders($data)
	// {
	// }




}
?>