This commit is contained in:
Laurent Destailleur 2011-09-20 22:55:11 +00:00
parent d579c0f405
commit 9740a10d4a
2 changed files with 91 additions and 81 deletions

View File

@ -32,102 +32,109 @@ include_once(DOL_DOCUMENT_ROOT.'/boutique/commande/class/boutiquecommande.class.
*/ */
class BoutiqueCommande class BoutiqueCommande
{ {
var $db ; var $db;
var $id ; var $id;
var $nom; var $nom;
function BoutiqueCommande($DB, $id=0)
{
$this->db = $DB;
$this->id = $id ;
$this->billing_adr = new Address(); /**
$this->delivry_adr = new Address(); * Constructor
*
* @param DoliDB $DB Database handler
*/
function BoutiqueCommande($DB)
{
$this->db = $DB;
$this->id = $id;
$this->total_ot_subtotal = 0; $this->billing_adr = new Address();
$this->total_ot_shipping = 0; $this->delivry_adr = new Address();
}
/** $this->total_ot_subtotal = 0;
* \brief Get object and lines from database $this->total_ot_shipping = 0;
* \param rowid id of object to load }
* \param ref Ref of order
* \return int >0 si ok, <0 si ko
*/
function fetch ($id,$ref='')
{
global $conf;
$sql = "SELECT orders_id, customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, last_modified, date_purchased, orders_status, orders_date_finished, currency, currency_value"; /**
$sql.= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders"; * Get object and lines from database
$sql.= " WHERE orders_id = ".$id; *
* @param int $id id of object to load
* @param string $ref Ref of order
* @return int >0 if OK, <0 if KO
*/
function fetch($id,$ref='')
{
global $conf;
$result = $this->db->query($sql); $sql = "SELECT orders_id, customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, last_modified, date_purchased, orders_status, orders_date_finished, currency, currency_value";
if ( $result ) $sql.= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders";
{ $sql.= " WHERE orders_id = ".$id;
$array = $this->db->fetch_array($result);
$this->id = $array["orders_id"]; $result = $this->db->query($sql);
$this->client_id = stripslashes($array["customers_id"]); if ( $result )
$this->client_name = stripslashes($array["customers_name"]); {
$array = $this->db->fetch_array($result);
$this->payment_method = stripslashes($array["payment_method"]); $this->id = $array["orders_id"];
$this->client_id = stripslashes($array["customers_id"]);
$this->client_name = stripslashes($array["customers_name"]);
$this->date = $this->db->jdate($array["date_purchased"]); $this->payment_method = stripslashes($array["payment_method"]);
$this->delivery_adr->name = stripslashes($array["delivery_name"]); $this->date = $this->db->jdate($array["date_purchased"]);
$this->delivery_adr->street = stripslashes($array["delivery_street_address"]);
$this->delivery_adr->cp = stripslashes($array["delivery_postcode"]);
$this->delivery_adr->city = stripslashes($array["delivery_city"]);
$this->delivery_adr->country = stripslashes($array["delivery_country"]);
$this->billing_adr->name = stripslashes($array["billing_name"]); $this->delivery_adr->name = stripslashes($array["delivery_name"]);
$this->billing_adr->street = stripslashes($array["billing_street_address"]); $this->delivery_adr->street = stripslashes($array["delivery_street_address"]);
$this->billing_adr->cp = stripslashes($array["billing_postcode"]); $this->delivery_adr->cp = stripslashes($array["delivery_postcode"]);
$this->billing_adr->city = stripslashes($array["billing_city"]); $this->delivery_adr->city = stripslashes($array["delivery_city"]);
$this->billing_adr->country = stripslashes($array["billing_country"]); $this->delivery_adr->country = stripslashes($array["delivery_country"]);
$this->db->free(); $this->billing_adr->name = stripslashes($array["billing_name"]);
$this->billing_adr->street = stripslashes($array["billing_street_address"]);
$this->billing_adr->cp = stripslashes($array["billing_postcode"]);
$this->billing_adr->city = stripslashes($array["billing_city"]);
$this->billing_adr->country = stripslashes($array["billing_country"]);
/* $this->db->free();
* Totaux
*/
$sql = "SELECT value, class ";
$sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders_total WHERE orders_id = $id";
$result = $this->db->query($sql); /*
if ( $result ) * Totaux
{ */
$num = $this->db->num_rows($result); $sql = "SELECT value, class ";
$sql .= " FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."orders_total WHERE orders_id = $id";
while ($i < $num) $result = $this->db->query($sql);
{ if ( $result )
$array = $this->db->fetch_array($result); {
if ($array["class"] == 'ot_total') $num = $this->db->num_rows($result);
{
$this->total_ot_total = $array["value"];
}
if ($array["class"] == 'ot_shipping')
{
$this->total_ot_shipping = $array["value"];
}
$i++;
}
}
else
{
print $this->db->error();
}
} while ($i < $num)
else {
{ $array = $this->db->fetch_array($result);
print $this->db->error(); if ($array["class"] == 'ot_total')
} {
$this->total_ot_total = $array["value"];
}
if ($array["class"] == 'ot_shipping')
{
$this->total_ot_shipping = $array["value"];
}
$i++;
}
}
else
{
print $this->db->error();
}
return $result; }
} else
{
print $this->db->error();
}
return $result;
}
} }
?> ?>

View File

@ -173,9 +173,12 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
/** /**
* Generate Header * Generate Header
* @param pdf Pdf object *
* @param page Current page number * @param PDF &$pdf Pdf object
* @param pages Total number of pages * @param int $page Current page number
* @param int $pages Total number of pages
* @param Translate $outputlangs Object language for output
* @return void
*/ */
function Header(&$pdf, $page, $pages, $outputlangs) function Header(&$pdf, $page, $pages, $outputlangs)
{ {