This commit is contained in:
Laurent Destailleur 2011-09-20 22:55:11 +00:00
parent 1f9f17247f
commit 030f960df3
3 changed files with 209 additions and 174 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

@ -96,15 +96,16 @@ class BonPrelevement extends CommonObject
/** /**
* Add facture to withdrawal * Add facture to withdrawal
* @param facture_id id invoice to add *
* @param client_id id invoice customer * @param int $facture_id id invoice to add
* @param client_nom name of cliente * @param int $client_id id invoice customer
* @param amount amount of invoice * @param string $client_nom name of cliente
* @param code_banque code of bank withdrawal * @param int $amount amount of invoice
* @param code_guichet code of bank's office * @param string $code_banque code of bank withdrawal
* @param number bank account number * @param string $code_guichet code of bank's office
* @param number_key number key of account number * @param string $number bank account number
* @return int >0 if OK, <0 if KO * @param string $number_key number key of account number
* @return int >0 if OK, <0 if KO
*/ */
function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
{ {
@ -153,15 +154,16 @@ class BonPrelevement extends CommonObject
/** /**
* Add line to withdrawal * Add line to withdrawal
* @param ligne_id id line to add *
* @param client_id id invoice customer * @param int &$line_id id line to add
* @param client_nom name of cliente * @param int $client_id id invoice customer
* @param amount amount of invoice * @param string $client_nom name of cliente
* @param code_banque code of bank withdrawal * @param int $amount amount of invoice
* @param code_guichet code of bank's office * @param string $code_banque code of bank withdrawal
* @param number bank account number * @param string $code_guichet code of bank's office
* @param number_key number key of account number * @param string $number bank account number
* @return int >0 if OK, <0 if KO * @param string $number_key number key of account number
* @return int >0 if OK, <0 if KO
*/ */
function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
{ {
@ -234,8 +236,9 @@ class BonPrelevement extends CommonObject
/** /**
* Read errors * Read errors
* @param error id of error *
* @return array of errors * @param int $error id of error
* @return array Array of errors
*/ */
function ReadError($error) function ReadError($error)
{ {
@ -248,8 +251,9 @@ class BonPrelevement extends CommonObject
/** /**
* Get object and lines from database * Get object and lines from database
* @param rowid id of object to load *
* @return int >0 if OK, <0 if KO * @param int $rowid id of object to load
* @return int >0 if OK, <0 if KO
*/ */
function fetch($rowid) function fetch($rowid)
{ {
@ -308,7 +312,10 @@ class BonPrelevement extends CommonObject
} }
/** /**
* @deprecated * Set credite
*
* @deprecated
* @return int <0 if KO, >0 if OK
*/ */
function set_credite() function set_credite()
{ {
@ -386,9 +393,10 @@ class BonPrelevement extends CommonObject
/** /**
* Set withdrawal to creditet status * Set withdrawal to creditet status
* @param user id of user *
* @param date date of action * @param User $user id of user
* @return int >0 if OK, <0 if KO * @param timestamp $date date of action
* @return int >0 if OK, <0 if KO
*/ */
function set_infocredit($user, $date) function set_infocredit($user, $date)
{ {
@ -508,10 +516,11 @@ class BonPrelevement extends CommonObject
/** /**
* Set withdrawal to transmited status * Set withdrawal to transmited status
* @param user id of user *
* @param date date of action * @param User $user id of user
* @param method method of transmision to bank * @param timestamp $date date of action
* @return int >0 if OK, <0 if KO * @param string $method method of transmision to bank
* @return int >0 if OK, <0 if KO
*/ */
function set_infotrans($user, $date, $method) function set_infotrans($user, $date, $method)
{ {
@ -575,6 +584,7 @@ class BonPrelevement extends CommonObject
/** /**
* Get invoice list * Get invoice list
*
* @return array id of invoices * @return array id of invoices
*/ */
function _get_list_factures() function _get_list_factures()
@ -623,7 +633,8 @@ class BonPrelevement extends CommonObject
/** /**
* Returns amount of withdrawal * Returns amount of withdrawal
* @return double total amount *
* @return double Total amount
*/ */
function SommeAPrelever() function SommeAPrelever()
{ {
@ -659,9 +670,10 @@ class BonPrelevement extends CommonObject
/** /**
* Get number of invoices to withdrawal * Get number of invoices to withdrawal
* @param banque bank *
* @param agence agence * @param int $banque bank
* @return int <O if KO, number of invoices if OK * @param int $agence agence
* @return int <O if KO, number of invoices if OK
*/ */
function NbFactureAPrelever($banque=0,$agence=0) function NbFactureAPrelever($banque=0,$agence=0)
{ {
@ -702,10 +714,11 @@ class BonPrelevement extends CommonObject
/** /**
* Create a withdraw * Create a withdraw
* @param banque code of bank *
* @param guichet code of banck office * @param int $banque code of bank
* @param mode real=do action, simu=test only * @param int $guichet code of banck office
* @return int <0 if KO, nbre of invoice withdrawed if OK * @param string $mode real=do action, simu=test only
* @return int <0 if KO, nbre of invoice withdrawed if OK
*/ */
function Create($banque=0, $guichet=0, $mode='real') function Create($banque=0, $guichet=0, $mode='real')
{ {
@ -855,7 +868,6 @@ class BonPrelevement extends CommonObject
/* /*
* Traitements * Traitements
*
*/ */
if (!$error) if (!$error)
{ {
@ -915,7 +927,6 @@ class BonPrelevement extends CommonObject
/* /*
* Creation process * Creation process
*
*/ */
if (!$error) if (!$error)
{ {
@ -938,8 +949,7 @@ class BonPrelevement extends CommonObject
* $fac[8] : client nom * $fac[8] : client nom
* $fac[2] : client id * $fac[2] : client id
*/ */
$ri = $bonprev->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $ri = $bonprev->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6]);
$fac[3], $fac[4], $fac[5], $fac[6]);
if ($ri <> 0) if ($ri <> 0)
{ {
$error++; $error++;
@ -1005,7 +1015,6 @@ class BonPrelevement extends CommonObject
/* /*
* Update total * Update total
*
*/ */
$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
@ -1023,7 +1032,6 @@ class BonPrelevement extends CommonObject
/* /*
* Rollback or Commit * Rollback or Commit
*
*/ */
if (!$error) if (!$error)
{ {
@ -1046,9 +1054,10 @@ class BonPrelevement extends CommonObject
/** /**
* Returns clickable name (with picto) * Returns clickable name (with picto)
* @param withpicto link with picto *
* @param option link target * @param int $withpicto link with picto
* @return string URL of target * @param string $option link target
* @return string URL of target
*/ */
function getNomUrl($withpicto=0,$option='') function getNomUrl($withpicto=0,$option='')
{ {
@ -1073,8 +1082,9 @@ class BonPrelevement extends CommonObject
/** /**
* Delete a notification def by id * Delete a notification def by id
* @param rowid id of notification *
* @return int 0 if OK, <0 if KO * @param int $rowid id of notification
* @return int 0 if OK, <0 if KO
*/ */
function DeleteNotificationById($rowid) function DeleteNotificationById($rowid)
{ {
@ -1095,9 +1105,10 @@ class BonPrelevement extends CommonObject
/** /**
* Delete a notification * Delete a notification
* @param user notification user *
* @param action notification action * @param User $user notification user
* @return int >0 if OK, <0 if KO * @param string $action notification action
* @return int >0 if OK, <0 if KO
*/ */
function DeleteNotification($user, $action) function DeleteNotification($user, $action)
{ {
@ -1118,9 +1129,11 @@ class BonPrelevement extends CommonObject
/** /**
* Add a notification * Add a notification
* @param user notification user *
* @param action notification action * @param DoliDB $db database handler
* @return int 0 if OK, <0 if KO * @param User $user notification user
* @param string $action notification action
* @return int 0 if OK, <0 if KO
*/ */
function AddNotification($db, $user, $action) function AddNotification($db, $user, $action)
{ {
@ -1148,13 +1161,13 @@ class BonPrelevement extends CommonObject
/** /**
* Generate a withdrawal file * Generate a withdrawal file. Generation Formats:
* Generation Formats: * France: CFONB
* France: CFONB * Spain: AEB19 (if external module EsAEB is enabled)
* Spain: AEB19 (if external module EsAEB is enabled) * Others: Warning message
* Others: Warning message
* File is generated with name this->filename * File is generated with name this->filename
* @return int 0 if OK, <0 if KO *
* @return int 0 if OK, <0 if KO
*/ */
//TODO: Optimize code to read lines in a single function //TODO: Optimize code to read lines in a single function
function Generate() function Generate()
@ -1198,15 +1211,17 @@ class BonPrelevement extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$esaeb19->agregaRecibo($idOrdenante, $esaeb19->agregaRecibo(
"idcliente".$i+1, $idOrdenante,
$obj->client_nom, "idcliente".$i+1,
$obj->code_banque, $obj->client_nom,
$obj->code_guichet, $obj->code_banque,
$obj->cle_rib, $obj->code_guichet,
$obj->number, $obj->cle_rib,
$obj->amount, $obj->number,
"Fra.".$obj->facnumber." ".$obj->amount); $obj->amount,
"Fra.".$obj->facnumber." ".$obj->amount
);
$this->total = $this->total + $obj->amount; $this->total = $this->total + $obj->amount;
@ -1291,14 +1306,16 @@ class BonPrelevement extends CommonObject
{ {
$row = $this->db->fetch_row($resql); $row = $this->db->fetch_row($resql);
$this->EnregDestinataire($row[0], $this->EnregDestinataire(
$row[1], $row[0],
$row[2], $row[1],
$row[3], $row[2],
$row[4], $row[3],
$row[5], $row[4],
$row[6], $row[5],
$row[7]); $row[6],
$row[7]
);
$this->total = $this->total + $row[5]; $this->total = $this->total + $row[5];
@ -1362,14 +1379,16 @@ class BonPrelevement extends CommonObject
/** /**
* Write recipient of request (customer) * Write recipient of request (customer)
* @param rowid id of line *
* @param client_nom name of customer * @param int $rowid id of line
* @param rib_banque code of bank * @param string $client_nom name of customer
* @param rib_guichet code of bank office * @param string $rib_banque code of bank
* @param rib_number bank account * @param string $rib_guichet code of bank office
* @param amount amount * @param string $rib_number bank account
* @param facnumber ref of invoice * @param float $amount amount
* @param facid id of invoice * @param string $facnumber ref of invoice
* @param int $facid id of invoice
* @return void
*/ */
function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $facnumber, $facid) function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $facnumber, $facid)
{ {
@ -1431,6 +1450,8 @@ class BonPrelevement extends CommonObject
/** /**
* Write sender of request (me) * Write sender of request (me)
*
* @return void
*/ */
function EnregEmetteur() function EnregEmetteur()
{ {
@ -1495,7 +1516,9 @@ class BonPrelevement extends CommonObject
/** /**
* Write end * Write end
* @param total total amount *
* @param int $total total amount
* @return void
*/ */
function EnregTotal($total) function EnregTotal($total)
{ {
@ -1554,8 +1577,9 @@ class BonPrelevement extends CommonObject
/** /**
* Return status label of object * Return status label of object
* @param mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto *
* @return string Label * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto
* @return string Label
*/ */
function getLibStatut($mode=0) function getLibStatut($mode=0)
{ {
@ -1564,9 +1588,10 @@ class BonPrelevement extends CommonObject
/** /**
* Return status label for a status * Return status label for a status
* @param statut id statut *
* @param mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto * @param int $statut id statut
* @return string Label * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto
* @return string Label
*/ */
function LibStatut($statut,$mode=0) function LibStatut($statut,$mode=0)
{ {

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)
{ {