本文整理汇总了PHP中DiscountAbsolute类的典型用法代码示例。如果您正苦于以下问题:PHP DiscountAbsolute类的具体用法?PHP DiscountAbsolute怎么用?PHP DiscountAbsolute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DiscountAbsolute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert_discount
/**
* Ajout d'une ligne remise fixe dans la commande, en base
* @param idremise Id de la remise fixe
* @return int >0 si ok, <0 si ko
*/
function insert_discount($idremise)
{
global $langs;
include_once DOL_DOCUMENT_ROOT . '/lib/price.lib.php';
include_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
$this->db->begin();
$remise = new DiscountAbsolute($this->db);
$result = $remise->fetch($idremise);
if ($result > 0) {
if ($remise->fk_facture) {
$this->error = $langs->trans("ErrorDiscountAlreadyUsed");
$this->db->rollback();
return -5;
}
$line = new OrderLine($this->db);
$line->fk_commande = $this->id;
$line->fk_remise_except = $remise->id;
$line->desc = $remise->description;
// Description ligne
$line->tva_tx = $remise->tva_tx;
$line->subprice = -$remise->amount_ht;
$line->price = -$remise->amount_ht;
$line->fk_product = 0;
// Id produit predefini
$line->qty = 1;
$line->remise = 0;
$line->remise_percent = 0;
$line->rang = -1;
$line->info_bits = 2;
$line->total_ht = -$remise->amount_ht;
$line->total_tva = -$remise->amount_tva;
$line->total_ttc = -$remise->amount_ttc;
$result = $line->insert();
if ($result > 0) {
$result = $this->update_price(1);
if ($result > 0) {
$this->db->commit();
return 1;
} else {
$this->db->rollback();
return -1;
}
} else {
$this->error = $line->error;
$this->db->rollback();
return -2;
}
} else {
$this->db->rollback();
return -2;
}
}
示例2: doc_getlinedesc
/**
* Return line description translated in outputlangs and encoded into UTF8
*
* @param Line $line Current line number (0 = first line, 1 = second line, ...)
* @param Translate $outputlangs Object langs for output
* @param int $hideref Hide reference
* @param int $hidedesc Hide description
* @param int $issupplierline Is it a line for a supplier object ?
* @return string String with line
*/
function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
{
global $db, $conf, $langs;
$idprod = $line->fk_product;
$label = $line->label;
if (empty($label)) {
$label = $line->libelle;
}
$desc = $line->desc;
if (empty($desc)) {
$desc = $line->description;
}
$ref_supplier = $line->ref_supplier;
if (empty($ref_supplier)) {
$ref_supplier = $line->ref_fourn;
}
// TODO Not yet saved for supplier invoices, only supplier orders
$note = $line->note;
if ($issupplierline) {
$prodser = new ProductFournisseur($db);
} else {
$prodser = new Product($db);
}
if ($idprod) {
$prodser->fetch($idprod);
// If a predefined product and multilang and on other lang, we renamed label with label translated
if ($conf->global->MAIN_MULTILANGS && $outputlangs->defaultlang != $langs->defaultlang) {
if (!empty($prodser->multilangs[$outputlangs->defaultlang]["libelle"]) && $label == $prodser->label) {
$label = $prodser->multilangs[$outputlangs->defaultlang]["libelle"];
}
if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) {
$desc = $prodser->multilangs[$outputlangs->defaultlang]["description"];
}
if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) {
$note = $prodser->multilangs[$outputlangs->defaultlang]["note"];
}
}
}
// Description short of product line
$libelleproduitservice = $label;
// Description long of product line
if ($desc && $desc != $label) {
if ($libelleproduitservice && empty($hidedesc)) {
$libelleproduitservice .= "\n";
}
if ($desc == '(CREDIT_NOTE)' && $line->fk_remise_except) {
$discount = new DiscountAbsolute($db);
$discount->fetch($line->fk_remise_except);
$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $discount->ref_facture_source);
} elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except) {
$discount = new DiscountAbsolute($db);
$discount->fetch($line->fk_remise_except);
$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $discount->ref_facture_source);
// Add date of deposit
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
echo ' (' . dol_print_date($discount->datec, 'day', '', $outputlangs) . ')';
}
} else {
if ($idprod) {
if (empty($hidedesc)) {
$libelleproduitservice .= $desc;
}
} else {
$libelleproduitservice .= $desc;
}
}
}
// If line linked to a product
if ($idprod) {
// On ajoute la ref
if ($prodser->ref) {
$prefix_prodserv = "";
$ref_prodserv = "";
if ($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS) {
if ($prodser->isservice()) {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service") . " ";
} else {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product") . " ";
}
}
if (empty($hideref)) {
if ($issupplierline) {
$ref_prodserv = $prodser->ref . ' (' . $outputlangs->trans("SupplierRef") . ' ' . $ref_supplier . ')';
} else {
$ref_prodserv = $prodser->ref;
}
// Show local ref only
$ref_prodserv .= " - ";
}
$libelleproduitservice = $prefix_prodserv . $ref_prodserv . $libelleproduitservice;
//.........这里部分代码省略.........
示例3: pdf_getlinedesc
/**
* Return line description translated in outputlangs and encoded into htmlentities and with <br>
*
* @param Object $object Object
* @param int $i Current line number (0 = first line, 1 = second line, ...)
* @param Translate $outputlangs Object langs for output
* @param int $hideref Hide reference
* @param int $hidedesc Hide description
* @param int $issupplierline Is it a line for a supplier object ?
* @return string String with line
*/
function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
{
global $db, $conf, $langs;
$idprod = !empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false;
$label = !empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '');
$desc = !empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '');
$ref_supplier = !empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '');
// TODO Not yet saved for supplier invoices, only supplier orders
$note = !empty($object->lines[$i]->note) ? $object->lines[$i]->note : '';
$dbatch = !empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false;
if ($issupplierline) {
$prodser = new ProductFournisseur($db);
} else {
$prodser = new Product($db);
}
if ($idprod) {
$prodser->fetch($idprod);
// If a predefined product and multilang and on other lang, we renamed label with label translated
if (!empty($conf->global->MAIN_MULTILANGS) && $outputlangs->defaultlang != $langs->defaultlang) {
$translatealsoifmodified = !empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED);
// By default if value was modified manually, we keep it (no translation because we don't have it)
// TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation
// ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion).
// Set label
// If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation.
//var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit;
$textwasmodified = $label == $prodser->label;
if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) {
$label = $prodser->multilangs[$outputlangs->defaultlang]["label"];
}
// Set desc
// Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no
$textwasmodified = false;
if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) {
$textwasmodified = strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401)) !== false;
} else {
$textwasmodified = $desc == $prodser->description;
}
if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) {
$desc = $prodser->multilangs[$outputlangs->defaultlang]["description"];
}
// Set note
$textwasmodified = $note == $prodser->note;
if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) {
$note = $prodser->multilangs[$outputlangs->defaultlang]["note"];
}
}
}
// Description short of product line
$libelleproduitservice = $label;
// Description long of product line
if (!empty($desc) && $desc != $label) {
if ($libelleproduitservice && empty($hidedesc)) {
$libelleproduitservice .= '__N__';
}
if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) {
$discount = new DiscountAbsolute($db);
$discount->fetch($object->lines[$i]->fk_remise_except);
$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $discount->ref_facture_source);
} elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) {
$discount = new DiscountAbsolute($db);
$discount->fetch($object->lines[$i]->fk_remise_except);
$libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $discount->ref_facture_source);
// Add date of deposit
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
echo ' (' . dol_print_date($discount->datec, 'day', '', $outputlangs) . ')';
}
} else {
if ($idprod) {
if (empty($hidedesc)) {
$libelleproduitservice .= $desc;
}
} else {
$libelleproduitservice .= $desc;
}
}
}
// If line linked to a product
if ($idprod) {
// We add ref
if ($prodser->ref) {
$prefix_prodserv = "";
$ref_prodserv = "";
if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
if ($prodser->isService()) {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service") . " ";
} else {
$prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product") . " ";
}
//.........这里部分代码省略.........
示例4: DiscountAbsolute
exit;
}
} else {
$error++;
$mesg = '<div class="error">' . $soc->error . '</div>';
}
}
} else {
$mesg = '<div class="error">' . $langs->trans("ErrorFieldFormat", $langs->trans("NewGlobalDiscount")) . '</div>';
}
}
if (GETPOST("action") == 'confirm_remove' && GETPOST("confirm") == 'yes') {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
$db->begin();
$discount = new DiscountAbsolute($db);
$result = $discount->fetch(GETPOST("remid"));
$result = $discount->delete($user);
if ($result > 0) {
$db->commit();
header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . GETPOST('id', 'int'));
// To avoid pb whith back
exit;
} else {
$mesg = '<div class="error">' . $discount->error . '</div>';
$db->rollback();
}
}
/*
* View
*/
示例5: insert
//.........这里部分代码省略.........
$sql .= " " . price2num($this->remise_percent) . ",";
$sql .= " " . price2num($this->subprice) . ",";
//$sql.= " ".price2num($this->price).",";
//$sql.= " ".($this->remise?price2num($this->remise):'0').","; // Deprecated
if ($this->fk_remise_except) {
$sql .= $this->fk_remise_except . ",";
} else {
$sql .= 'null,';
}
if ($this->date_start) {
$sql .= "'" . $this->db->idate($this->date_start) . "',";
} else {
$sql .= 'null,';
}
if ($this->date_end) {
$sql .= "'" . $this->db->idate($this->date_end) . "',";
} else {
$sql .= 'null,';
}
$sql .= ' ' . $this->fk_code_ventilation . ',';
$sql .= ' ' . $this->fk_export_compta . ',';
$sql .= ' ' . $this->rang . ',';
$sql .= ' ' . $this->special_code . ',';
if (isset($this->fk_fournprice)) {
$sql .= ' ' . $this->fk_fournprice . ',';
} else {
$sql .= ' null,';
}
if (isset($this->pa_ht)) {
$sql .= ' ' . price2num($this->pa_ht) . ',';
} else {
$sql .= ' null,';
}
$sql .= " '" . $this->info_bits . "',";
$sql .= " " . price2num($this->total_ht) . ",";
$sql .= " " . price2num($this->total_tva) . ",";
$sql .= " " . price2num($this->total_ttc) . ",";
$sql .= " " . price2num($this->total_localtax1) . ",";
$sql .= " " . price2num($this->total_localtax2);
$sql .= ')';
dol_syslog(get_class($this) . "::insert sql=" . $sql);
$resql = $this->db->query($sql);
if ($resql) {
$this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX . 'facturedet');
// Si fk_remise_except defini, on lie la remise a la facture
// ce qui la flague comme "consommee".
if ($this->fk_remise_except) {
$discount = new DiscountAbsolute($this->db);
$result = $discount->fetch($this->fk_remise_except);
if ($result >= 0) {
// Check if discount was found
if ($result > 0) {
// Check if discount not already affected to another invoice
if ($discount->fk_facture) {
$this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id);
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
} else {
$result = $discount->link_to_invoice($this->rowid, 0);
if ($result < 0) {
$this->error = $discount->error;
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
}
} else {
$this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded");
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
} else {
$this->error = $discount->error;
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
}
if (!$notrigger) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('LINEBILL_INSERT', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
$this->db->commit();
return $this->rowid;
} else {
$this->error = $this->db->error();
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -2;
}
}
示例6: getAvailableDiscounts
/**
* \brief Renvoie montant TTC des reductions/avoirs en cours disponibles de la societe
* \param user Filtre sur un user auteur des remises
* \param filter Filtre autre
* \param maxvalue Filter on max value for discount
* \return int <0 if KO, Credit note amount otherwise
*/
function getAvailableDiscounts($user='',$filter='',$maxvalue=0)
{
require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
$discountstatic=new DiscountAbsolute($this->db);
$result=$discountstatic->getAvailableDiscounts($this,$user,$filter,$maxvalue);
if ($result >= 0)
{
return $result;
}
else
{
$this->error=$discountstatic->error;
return -1;
}
}
示例7: _createAvoir
function _createAvoir(&$PDOdb, &$db, &$user, &$conf, &$langs)
{
dol_include_once('/compta/facture/class/facture.class.php');
dol_include_once('/core/class/discount.class.php');
$sql = _getSql2();
$PDOdb->Execute($sql);
$TFacnumberFetchError = array();
$TFacnumberCreateError = array();
$TDiscountCreateError = array();
$nbValidate = 0;
while ($row = $PDOdb->Get_line()) {
$fk_soc = $row->fk_soc;
$facnumber = $row->facnumber;
$factureImpayee = new Facture($db);
if ($factureImpayee->fetch(null, $facnumber) <= 0) {
$TFacnumberFetchError[] = $facnumber;
continue;
}
$dateinvoice = dol_mktime(12, 0, 0, date('m'), date('d'), date('Y'));
$facture = new Facture($db);
$facture->socid = $fk_soc;
$facture->fk_facture_source = $factureImpayee->id;
$facture->type = Facture::TYPE_CREDIT_NOTE;
$facture->date = $dateinvoice;
if ($facture->create($user) <= 0) {
$TFacnumberCreateError[] = $facnumber;
continue;
}
foreach ($factureImpayee->lines as $line) {
$line->fk_facture = $facture->id;
$line->subprice = -$line->subprice;
// invert price for object
$line->pa_ht = -$line->pa_ht;
$line->total_ht = -$line->total_ht;
$line->total_tva = -$line->total_tva;
$line->total_ttc = -$line->total_ttc;
$line->total_localtax1 = -$line->total_localtax1;
$line->total_localtax2 = -$line->total_localtax2;
$line->insert();
$facture->lines[] = $line;
// insert new line in current object
}
$facture->update_price(1);
$facture->validate($user);
$discountcheck = new DiscountAbsolute($db);
$result = $discountcheck->fetch(0, $facture->id);
if (!empty($discountcheck->id)) {
//can't convert
$facture->delete();
continue;
}
$i = 0;
$amount_ht = $amount_tva = $amount_ttc = array();
foreach ($facture->lines as $line) {
if ($line->total_ht != 0) {
// no need to create discount if amount is null
$amount_ht[$line->tva_tx] += $line->total_ht;
$amount_tva[$line->tva_tx] += $line->total_tva;
$amount_ttc[$line->tva_tx] += $line->total_ttc;
$i++;
}
}
// Insert one discount by VAT rate category
$discount = new DiscountAbsolute($db);
$discount->description = '(CREDIT_NOTE)';
$discount->tva_tx = abs($facture->total_ttc);
$discount->fk_soc = $facture->socid;
$discount->fk_facture_source = $facture->id;
foreach ($amount_ht as $tva_tx => $xxx) {
$discount->amount_ht = abs($amount_ht[$tva_tx]);
$discount->amount_tva = abs($amount_tva[$tva_tx]);
$discount->amount_ttc = abs($amount_ttc[$tva_tx]);
$discount->tva_tx = abs($tva_tx);
$result = $discount->create($user);
if ($result < 0) {
$TDiscountCreateError[] = $facnumber;
$error++;
break;
}
$result = $facture->set_paid($user);
$result = $discount->link_to_invoice(0, $factureImpayee->id);
$r = $factureImpayee->set_paid($user);
}
/******/
$nbValidate++;
}
if ($nbValidate) {
setEventMessages($langs->trans('sendinvoicetoadherentAvoirValidate', $nbValidate), null);
}
if (count($TFacnumberFetchError) > 0) {
setEventMessages($langs->trans('sendinvoicetoadherentErrorFetchFacture', count($TFacnumberFetchError)), null, 'errors');
}
if (count($TFacnumberCreateError) > 0) {
setEventMessages($langs->trans('sendinvoicetoadherentErrorCreateAvoir', count($TFacnumberCreateError)), null, 'errors');
}
$_SESSION['SENDTOINVOICETOADHERENT_TFETCHERROR'] = $TFacnumberFetchError;
$_SESSION['SENDTOINVOICETOADHERENT_TCREATEERROR'] = $TFacnumberCreateError;
header('Location: ' . dol_buildpath('/sendinvoicetoadherent/sendinvoicetoadherent.php?action=listAvoir', 2));
exit;
}
开发者ID:ATM-Consulting,项目名称:dolibarr_module_sendinvoicetoadherent,代码行数:100,代码来源:sendinvoicetoadherent.php
示例8: printOriginLine
/**
* Return HTML with a line of table array of source object lines
* TODO Move this and previous function into output html class file (htmlline.class.php).
* If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
*
* @param array $line Line
* @param string $var Var
* @return void
*/
function printOriginLine($line, $var)
{
global $conf, $langs, $bc;
//var_dump($line);
$date_start = $line->date_debut_prevue;
if ($line->date_debut_reel) {
$date_start = $line->date_debut_reel;
}
$date_end = $line->date_fin_prevue;
if ($line->date_fin_reel) {
$date_end = $line->date_fin_reel;
}
$this->tpl['label'] = '';
if (!empty($line->fk_parent_line)) {
$this->tpl['label'] .= img_picto('', 'rightarrow');
}
if (($line->info_bits & 2) == 2) {
$discount = new DiscountAbsolute($this->db);
$discount->fk_soc = $this->socid;
$this->tpl['label'] .= $discount->getNomUrl(0, 'discount');
} else {
if ($line->fk_product) {
$productstatic = new Product($this->db);
$productstatic->id = $line->fk_product;
$productstatic->ref = $line->ref;
$productstatic->type = $line->fk_product_type;
$this->tpl['label'] .= $productstatic->getNomUrl(1);
$this->tpl['label'] .= $line->label ? ' - ' . $line->label : '';
// Dates
if ($line->product_type == 1 && ($date_start || $date_end)) {
$this->tpl['label'] .= get_date_range($date_start, $date_end);
}
} else {
$this->tpl['label'] .= $line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''), 'service') : img_object($langs->trans(''), 'product'));
$this->tpl['label'] .= $line->label ? ' ' . $line->label : '';
// Dates
if ($line->product_type == 1 && ($date_start || $date_end)) {
$this->tpl['label'] .= get_date_range($date_start, $date_end);
}
}
}
if ($line->desc) {
if ($line->desc == '(CREDIT_NOTE)') {
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
$this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
} elseif ($line->desc == '(DEPOSIT)') {
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
$this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
} else {
$this->tpl['description'] = dol_trunc($line->desc, 60);
}
} else {
$this->tpl['description'] = ' ';
}
$this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
$this->tpl['price'] = price($line->subprice);
$this->tpl['qty'] = ($line->info_bits & 2) != 2 ? $line->qty : ' ';
$this->tpl['remise_percent'] = ($line->info_bits & 2) != 2 ? vatrate($line->remise_percent, true) : ' ';
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
foreach ($dirtpls as $reldir) {
$res = @(include dol_buildpath($reldir . '/originproductline.tpl.php'));
if ($res) {
break;
}
}
}
示例9: count
if ($closeOrders) {
$objectsrc->classifyBilled();
$objectsrc->setStatut(3);
}
$lines = $objectsrc->lines;
if (empty($lines) && method_exists($objectsrc, 'fetch_lines')) {
$objectsrc->fetch_lines();
$lines = $objectsrc->lines;
}
$fk_parent_line = 0;
$num = count($lines);
for ($i = 0; $i < $num; $i++) {
$desc = $lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle;
if ($lines[$i]->subprice < 0) {
// Negative line, we create a discount line
$discount = new DiscountAbsolute($db);
$discount->fk_soc = $object->socid;
$discount->amount_ht = abs($lines[$i]->total_ht);
$discount->amount_tva = abs($lines[$i]->total_tva);
$discount->amount_ttc = abs($lines[$i]->total_ttc);
$discount->tva_tx = $lines[$i]->tva_tx;
$discount->fk_user = $user->id;
$discount->description = $desc;
$discountid = $discount->create($user);
if ($discountid > 0) {
$result = $object->insert_discount($discountid);
//$result=$discount->link_to_invoice($lineid,$id);
} else {
setEventMessages($discount->error, $discount->errors, 'errors');
$error++;
break;
示例10: foreach
$listofpayments = $object->getListOfPayments();
foreach ($listofpayments as $paym) {
if ($paym['type'] != 'PNT') {
if ($paym['type'] != 'LIQ') {
echo '<tr><th nowrap="nowrap">' . $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . '</th><td nowrap="nowrap">' . price($paym['amount'], "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
} else {
echo '<tr><th nowrap="nowrap">' . $terminal->select_Paymentname(dol_getIdFromCode($db, $paym['type'], 'c_paiement')) . '</th><td nowrap="nowrap">' . price($paym['amount'] - (($object->type > 1 ? $diff_payment * -1 : $diff_payment) < 0 ? $diff_payment : 0), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
}
}
}
if (!empty($conf->rewards->enabled)) {
if ($moneypoints != 0) {
echo '<tr><th nowrap="nowrap">' . $usepoints . " " . $langs->trans("Points") . '</th><td nowrap="nowrap">' . price($moneypoints, "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
}
}
$discount = new DiscountAbsolute($db);
$result = $discount->fetch(0, $object->id);
if ($result > 0) {
echo '<tr><th nowrap="nowrap"></th><td nowrap="nowrap">' . $langs->trans("ReductionConvert") . '</td></tr>';
} else {
echo '<tr><th nowrap="nowrap">' . (($object->type > 1 ? $diff_payment * -1 : $diff_payment) < 0 ? $langs->trans("CustomerRet") : $langs->trans("CustomerDeb")) . '</th><td nowrap="nowrap">' . price(abs($diff_payment), "", "", "", "", 2) . " " . $langs->trans(currency_name($conf->currency)) . "</td></tr>";
}
if ($points != 0 && !empty($conf->rewards->enabled)) {
echo '<tr><th nowrap="nowrap">' . $langs->trans("TotalPointsInvoice") . '</th><td nowrap="nowrap">' . price($points, "", "", "", "", 2) . " " . $langs->trans('Points') . "</td></tr>";
$total_points = $rewards->getCustomerPoints($object->socid);
echo '<tr><th nowrap="nowrap">' . $langs->trans("DispoPoints") . '</th><td nowrap="nowrap">' . price($total_points, "", "", "", "", 2) . " " . $langs->trans('Points') . "</td></tr>";
}
?>
</table>
<div class="note"><p><?php
示例11: testDiscountDelete
/**
* testDiscountDelete
*
* @param int $id Id of discount
* @return int
*
* @depends testDiscountFetch
* The depends says test is run only if previous is ok
*/
public function testDiscountDelete($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new DiscountAbsolute($this->savdb);
$result=$localobject->fetch($id);
$result=$localobject->delete($user);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
示例12: createFactureFromObject
static function createFactureFromObject(&$object)
{
global $db, $conf, $user, $langs;
dol_include_once('/compta/facture/class/facture.class.php');
$langs->load('grapefruit@grapefruit');
$dateinvoice = dol_mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$f = new Facture($db);
$f->socid = $object->socid;
$f->type = Facture::TYPE_STANDARD;
$f->number = $_POST['facnumber'];
$f->date = $dateinvoice;
$f->note_public = $object->note_public;
$f->note_private = $object->note_private;
$f->ref_client = $object->ref_client;
$f->fk_project = $object->fk_project;
$f->cond_reglement_id = $object->cond_reglement_id;
$f->mode_reglement_id = $object->mode_reglement_id;
$origin = 'commande';
$originid = $object->id;
$f->linked_objects[$origin] = $originid;
$id = $f->create($user);
$lines = $object->lines;
if (empty($lines) && method_exists($object, 'fetch_lines')) {
$object->fetch_lines();
$lines = $object->lines;
}
$fk_parent_line = 0;
$num = count($lines);
for ($i = 0; $i < $num; $i++) {
$label = !empty($lines[$i]->label) ? $lines[$i]->label : '';
$desc = !empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle;
if ($f->situation_counter == 1) {
$lines[$i]->situation_percent = 0;
}
if ($lines[$i]->subprice < 0) {
// Negative line, we create a discount line
$discount = new DiscountAbsolute($db);
$discount->fk_soc = $f->socid;
$discount->amount_ht = abs($lines[$i]->total_ht);
$discount->amount_tva = abs($lines[$i]->total_tva);
$discount->amount_ttc = abs($lines[$i]->total_ttc);
$discount->tva_tx = $lines[$i]->tva_tx;
$discount->fk_user = $user->id;
$discount->description = $desc;
$discountid = $discount->create($user);
if ($discountid > 0) {
$result = $f->insert_discount($discountid);
// This include link_to_invoice
} else {
setEventMessages($discount->error, $discount->errors, 'errors');
$error++;
break;
}
} else {
// Positive line
$product_type = $lines[$i]->product_type ? $lines[$i]->product_type : 0;
// Date start
$date_start = false;
if ($lines[$i]->date_debut_prevue) {
$date_start = $lines[$i]->date_debut_prevue;
}
if ($lines[$i]->date_debut_reel) {
$date_start = $lines[$i]->date_debut_reel;
}
if ($lines[$i]->date_start) {
$date_start = $lines[$i]->date_start;
}
// Date end
$date_end = false;
if ($lines[$i]->date_fin_prevue) {
$date_end = $lines[$i]->date_fin_prevue;
}
if ($lines[$i]->date_fin_reel) {
$date_end = $lines[$i]->date_fin_reel;
}
if ($lines[$i]->date_end) {
$date_end = $lines[$i]->date_end;
}
// Reset fk_parent_line for no child products and special product
if ($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line) || $lines[$i]->product_type == 9) {
$fk_parent_line = 0;
}
// Extrafields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
$lines[$i]->fetch_optionals($lines[$i]->rowid);
$array_options = $lines[$i]->array_options;
}
// View third's localtaxes for now
$localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $f->client);
$localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $f->client);
$result = $f->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $f->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit);
if ($result > 0) {
$lineid = $result;
} else {
$lineid = 0;
$error++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) {
//.........这里部分代码省略.........
示例13: printOriginLine
/**
* Return HTML with a line of table array of source object lines
* TODO Move this and previous function into output html class file (htmlline.class.php).
* If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
* @param line
* @param var
*/
function printOriginLine($line, $var)
{
global $langs, $bc;
//var_dump($line);
$date_start = $line->date_debut_prevue;
if ($line->date_debut_reel) {
$date_start = $line->date_debut_reel;
}
$date_end = $line->date_fin_prevue;
if ($line->date_fin_reel) {
$date_end = $line->date_fin_reel;
}
$this->tpl['label'] = '';
if (!empty($line->fk_parent_line)) {
$this->tpl['label'] .= img_picto('', 'rightarrow');
}
if (($line->info_bits & 2) == 2) {
$discount = new DiscountAbsolute($db);
$discount->fk_soc = $this->socid;
$this->tpl['label'] .= $discount->getNomUrl(0, 'discount');
} else {
if ($line->fk_product) {
$productstatic = new Product($this->db);
$productstatic->id = $line->fk_product;
$productstatic->ref = $line->ref;
$productstatic->type = $line->fk_product_type;
$this->tpl['label'] .= $productstatic->getNomUrl(1);
$this->tpl['label'] .= $line->label ? ' - ' . $line->label : '';
// Dates
if ($line->product_type == 1 && ($date_start || $date_end)) {
$this->tpl['label'] .= get_date_range($date_start, $date_end);
}
} else {
$this->tpl['label'] .= $line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''), 'service') : img_object($langs->trans(''), 'product'));
$this->tpl['label'] .= $line->label ? ' ' . $line->label : '';
// Dates
if ($line->product_type == 1 && ($date_start || $date_end)) {
$this->tpl['label'] .= get_date_range($date_start, $date_end);
}
}
}
if ($line->desc) {
if ($line->desc == '(CREDIT_NOTE)') {
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
$this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
} elseif ($line->desc == '(DEPOSIT)') {
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
$this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
} else {
$this->tpl['description'] = dol_trunc($line->desc, 60);
}
} else {
$this->tpl['description'] = ' ';
}
$this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
$this->tpl['price'] = price($line->subprice);
$this->tpl['qty'] = ($line->info_bits & 2) != 2 ? $line->qty : ' ';
$this->tpl['remise_percent'] = ($line->info_bits & 2) != 2 ? vatrate($line->remise_percent, true) : ' ';
include DOL_DOCUMENT_ROOT . '/core/tpl/originproductline.tpl.php';
}
示例14: insert
//.........这里部分代码省略.........
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'facturedet';
$sql .= ' (fk_facture, fk_parent_line, label, description, qty,';
$sql .= ' tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql .= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,';
$sql .= ' date_start, date_end, fk_code_ventilation, ';
$sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,';
$sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2)';
$sql .= " VALUES (" . $this->fk_facture . ",";
$sql .= " " . ($this->fk_parent_line > 0 ? "'" . $this->fk_parent_line . "'" : "null") . ",";
$sql .= " " . (!empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : "null") . ",";
$sql .= " '" . $this->db->escape($this->desc) . "',";
$sql .= " " . price2num($this->qty) . ",";
$sql .= " " . price2num($this->tva_tx) . ",";
$sql .= " " . price2num($this->localtax1_tx) . ",";
$sql .= " " . price2num($this->localtax2_tx) . ",";
$sql .= " '" . $this->localtax1_type . "',";
$sql .= " '" . $this->localtax2_type . "',";
$sql .= ' ' . (!empty($this->fk_product) ? $this->fk_product : "null") . ',';
$sql .= " " . $this->product_type . ",";
$sql .= " " . price2num($this->remise_percent) . ",";
$sql .= " " . price2num($this->subprice) . ",";
$sql .= ' ' . (!empty($this->fk_remise_except) ? $this->fk_remise_except : "null") . ',';
$sql .= " " . (!empty($this->date_start) ? "'" . $this->db->idate($this->date_start) . "'" : "null") . ",";
$sql .= " " . (!empty($this->date_end) ? "'" . $this->db->idate($this->date_end) . "'" : "null") . ",";
$sql .= ' ' . $this->fk_code_ventilation . ',';
$sql .= ' ' . $this->rang . ',';
$sql .= ' ' . $this->special_code . ',';
$sql .= ' ' . (!empty($this->fk_fournprice) ? $this->fk_fournprice : "null") . ',';
$sql .= ' ' . price2num($this->pa_ht) . ',';
$sql .= " '" . $this->info_bits . "',";
$sql .= " " . price2num($this->total_ht) . ",";
$sql .= " " . price2num($this->total_tva) . ",";
$sql .= " " . price2num($this->total_ttc) . ",";
$sql .= " " . price2num($this->total_localtax1) . ",";
$sql .= " " . price2num($this->total_localtax2);
$sql .= ')';
dol_syslog(get_class($this) . "::insert", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX . 'facturedet');
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$this->id = $this->rowid;
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
// Si fk_remise_except defini, on lie la remise a la facture
// ce qui la flague comme "consommee".
if ($this->fk_remise_except) {
$discount = new DiscountAbsolute($this->db);
$result = $discount->fetch($this->fk_remise_except);
if ($result >= 0) {
// Check if discount was found
if ($result > 0) {
// Check if discount not already affected to another invoice
if ($discount->fk_facture) {
$this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id);
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
} else {
$result = $discount->link_to_invoice($this->rowid, 0);
if ($result < 0) {
$this->error = $discount->error;
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
}
} else {
$this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded");
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
} else {
$this->error = $discount->error;
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
}
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEBILL_INSERT', $user);
if ($result < 0) {
$this->db->rollback();
return -2;
}
// End call triggers
}
$this->db->commit();
return $this->rowid;
} else {
$this->error = $this->db->error();
$this->db->rollback();
return -2;
}
}
示例15: insert
//.........这里部分代码省略.........
$sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,';
$sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,';
$sql .= ' situation_percent, fk_prev_id,';
$sql .= ' fk_unit)';
$sql .= " VALUES (" . $this->fk_facture . ",";
$sql .= " " . ($this->fk_parent_line > 0 ? "'" . $this->fk_parent_line . "'" : "null") . ",";
$sql .= " " . (!empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : "null") . ",";
$sql .= " '" . $this->db->escape($this->desc) . "',";
$sql .= " " . price2num($this->qty) . ",";
$sql .= " " . price2num($this->tva_tx) . ",";
$sql .= " " . price2num($this->localtax1_tx) . ",";
$sql .= " " . price2num($this->localtax2_tx) . ",";
$sql .= " '" . $this->localtax1_type . "',";
$sql .= " '" . $this->localtax2_type . "',";
$sql .= ' ' . (!empty($this->fk_product) ? $this->fk_product : "null") . ',';
$sql .= " " . $this->product_type . ",";
$sql .= " " . price2num($this->remise_percent) . ",";
$sql .= " " . price2num($this->subprice) . ",";
$sql .= ' ' . (!empty($this->fk_remise_except) ? $this->fk_remise_except : "null") . ',';
$sql .= " " . (!empty($this->date_start) ? "'" . $this->db->idate($this->date_start) . "'" : "null") . ",";
$sql .= " " . (!empty($this->date_end) ? "'" . $this->db->idate($this->date_end) . "'" : "null") . ",";
$sql .= ' ' . $this->fk_code_ventilation . ',';
$sql .= ' ' . $this->rang . ',';
$sql .= ' ' . $this->special_code . ',';
$sql .= ' ' . (!empty($this->fk_fournprice) ? $this->fk_fournprice : "null") . ',';
$sql .= ' ' . price2num($this->pa_ht) . ',';
$sql .= " '" . $this->info_bits . "',";
$sql .= " " . price2num($this->total_ht) . ",";
$sql .= " " . price2num($this->total_tva) . ",";
$sql .= " " . price2num($this->total_ttc) . ",";
$sql .= " " . price2num($this->total_localtax1) . ",";
$sql .= " " . price2num($this->total_localtax2);
$sql .= ", " . $this->situation_percent;
$sql .= ", " . $this->fk_prev_id;
$sql .= ", " . (!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql .= ')';
dol_syslog(get_class($this) . "::insert", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX . 'facturedet');
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$this->id = $this->rowid;
$result = $this->insertExtraFields();
if ($result < 0) {
$error++;
}
}
// Si fk_remise_except defini, on lie la remise a la facture
// ce qui la flague comme "consommee".
if ($this->fk_remise_except) {
$discount = new DiscountAbsolute($this->db);
$result = $discount->fetch($this->fk_remise_except);
if ($result >= 0) {
// Check if discount was found
if ($result > 0) {
// Check if discount not already affected to another invoice
if ($discount->fk_facture) {
$this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id);
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
} else {
$result = $discount->link_to_invoice($this->rowid, 0);
if ($result < 0) {
$this->error = $discount->error;
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
}
} else {
$this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded");
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
} else {
$this->error = $discount->error;
dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
}
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEBILL_INSERT', $user);
if ($result < 0) {
$this->db->rollback();
return -2;
}
// End call triggers
}
$this->db->commit();
return $this->rowid;
} else {
$this->error = $this->db->error();
$this->db->rollback();
return -2;
}
}