本文整理汇总了PHP中DiscountAbsolute::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscountAbsolute::fetch方法的具体用法?PHP DiscountAbsolute::fetch怎么用?PHP DiscountAbsolute::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscountAbsolute
的用法示例。
在下文中一共展示了DiscountAbsolute::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DiscountAbsolute
/**
* 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: 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;
}
}
示例3: 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;
//.........这里部分代码省略.........
示例4: 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") . " ";
}
//.........这里部分代码省略.........
示例5: DiscountAbsolute
}
} 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
*/
$form = new Form($db);
示例6: 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;
}
}
示例7: addPaymentFac
/**
*
* Add facture Payment
*
* @param array $aryTicket Ticket data array
*/
private function addPaymentFac($aryTicket)
{
global $db, $langs, $conf;
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
$now = dol_now();
$userstatic = new User($db);
$error = 0;
if (!$aryTicket['employeeId']) {
$employee = $_SESSION['uid'];
} else {
$employee = $aryTicket['employeeId'];
}
$userstatic->fetch($employee);
$max_ite = 3;
if ($aryTicket['convertDis']) {
require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
$object = new Facture($db);
$object->fetch($aryTicket['id']);
$object->fetch_thirdparty();
// Check if there is already a discount (protection to avoid duplicate creation when resubmit post)
$discountcheck = new DiscountAbsolute($db);
$result = $discountcheck->fetch(0, $object->id);
$canconvert = 0;
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->paye == 0 && empty($discountcheck->id)) {
$canconvert = 1;
}
// we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc)
if ($canconvert) {
$db->begin();
// Boucle sur chaque taux de tva
$i = 0;
foreach ($object->lines as $line) {
$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);
if ($object->type == Facture::TYPE_CREDIT_NOTE) {
$discount->description = $langs->trans('DiscountOf', $object->ref);
}
$discount->tva_tx = abs($object->total_ttc);
$discount->fk_soc = $object->socid;
$discount->fk_facture_source = $object->id;
$error = 0;
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);
$paiement_id = $discount->create($userstatic);
if ($paiement_id < 0) {
$error++;
break;
}
}
if (empty($error)) {
// Classe facture
$paiement_id = $object->set_paid($user);
if ($result >= 0) {
//$mesgs[]='OK'.$discount->id;
$db->commit();
} else {
$db->rollback();
}
} else {
$db->rollback();
}
}
} else {
if ($aryTicket['type'] == 1) {
if ($aryTicket['total'] > $aryTicket['customerpay'] && $aryTicket['difpayment'] == 0) {
dol_include_once('/rewards/class/rewards.class.php');
$reward = new Rewards($db);
$facture = new Facture($db);
$facture->fetch($aryTicket['id']);
$modepay[4] = dol_getIdFromCode($db, 'PNT', 'c_paiement');
$amount[4] = $aryTicket['total'] - $aryTicket['customerpay'];
$result = $reward->create($facture, price2num($amount[4]) / $conf->global->REWARDS_DISCOUNT);
$max_ite++;
$amount[4] = $amount[4] * -1;
//TODO tot molt bonico, pero que pasa si no gaste punts?
}
$aryTicket['total'] = $aryTicket['total'] * -1;
$aryTicket['customerpay1'] = $aryTicket['customerpay1'] * -1;
$aryTicket['customerpay2'] = $aryTicket['customerpay2'] * -1;
$aryTicket['customerpay3'] = $aryTicket['customerpay3'] * -1;
}
$cash = new Cash($db);
$terminal = $_SESSION['TERMINAL_ID'];
$cash->fetch($terminal);
if ($aryTicket['customerpay1'] != 0) {
$bankaccountid[1] = $cash->fk_paycash;
//.........这里部分代码省略.........
示例8: _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
示例9: 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;
}
}
}
示例10: DiscountAbsolute
if ($line->description == '(DEPOSIT)') {
$txt = $langs->trans("Deposit");
}
//else $txt=$langs->trans("Discount");
print $txt;
?>
</a>
<?php
if ($line->description) {
if ($line->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) {
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
echo ($txt ? ' - ' : '') . $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
} elseif ($line->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) {
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
echo ($txt ? ' - ' : '') . $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
// Add date of deposit
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
echo ' (' . dol_print_date($discount->datec) . ')';
}
} else {
echo ($txt ? ' - ' : '') . dol_htmlentitiesbr($line->description);
}
}
} else {
$format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE ? 'dayhour' : 'day';
if ($line->fk_product > 0) {
echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, !empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '');
// Show range
echo get_date_range($line->date_start, $line->date_end, $format);
示例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: 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';
}
示例13: 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;
}
}
示例14: DiscountAbsolute
}
else
{
print '<td>';
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
if (($objp->info_bits & 2) == 2)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->socid.'">';
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
print '</a>';
if ($objp->description)
{
if ($objp->description == '(CREDIT_NOTE)')
{
$discount=new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except);
print ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
}
else
{
print ' - '.nl2br($objp->description);
}
}
}
else
{
if ($type==1) $text = img_object($langs->trans('Service'),'service');
else $text = img_object($langs->trans('Product'),'product');
print $text.' '.nl2br($objp->description);
// Show range
示例15: DiscountAbsolute
}
$head = facture_prepare_head($fac);
dol_fiche_head($head, 'standingorders', $langs->trans('InvoiceCustomer'),0,'bill');
/*
* Facture
*/
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="5">';
$morehtmlref='';
$discount=new DiscountAbsolute($db);
$result=$discount->fetch(0,$fac->id);
if ($result > 0)
{
$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
}
if ($result < 0)
{
dol_print_error('',$discount->error);
}
print $html->showrefnav($fac,'ref','',1,'facnumber','ref',$morehtmlref);
print "</td></tr>";
// Third party
print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="5">'.$soc->getNomUrl(1,'compta');
print ' (<a href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$fac->socid.'">'.$langs->trans('OtherBills').'</a>)</td>';