本文整理匯總了PHP中Facture::fetch_thirdparty方法的典型用法代碼示例。如果您正苦於以下問題:PHP Facture::fetch_thirdparty方法的具體用法?PHP Facture::fetch_thirdparty怎麽用?PHP Facture::fetch_thirdparty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Facture
的用法示例。
在下文中一共展示了Facture::fetch_thirdparty方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Header
Header('Location: ' . $loc);
exit;
} else {
$db->rollback();
}
}
/*
* View
*/
llxHeader();
$html = new Form($db);
if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') {
$facture = new Facture($db);
$result = $facture->fetch($facid);
if ($result >= 0) {
$facture->fetch_thirdparty();
$title = '';
if ($facture->type != 2) {
$title .= $langs->trans("EnterPaymentReceivedFromCustomer");
}
if ($facture->type == 2) {
$title .= $langs->trans("EnterPaymentDueToCustomer");
}
print_fiche_titre($title);
dol_htmloutput_errors($errmsg);
// Bouchon
if ($facture->type == 2) {
print $langs->trans("FeatureNotYetAvailable");
llxFooter();
exit;
}
示例2: addPaymentToBank
/**
* Add a record into bank for payment with links between this bank record and invoices of payment.
* All payment properties (this->amount, this->amounts, ...) must have been set first like after a call to create().
*
* @param User $user Object of user making payment
* @param string $mode 'payment', 'payment_supplier'
* @param string $label Label to use in bank record
* @param int $accountid Id of bank account to do link with
* @param string $emetteur_nom Name of transmitter
* @param string $emetteur_banque Name of bank
* @param int $notrigger No trigger
* @return int <0 if KO, bank_line_id if OK
*/
function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0)
{
global $conf, $langs, $user;
$error = 0;
$bank_line_id = 0;
if (!empty($conf->banque->enabled)) {
if ($accountid <= 0) {
$this->error = 'Bad value for parameter accountid';
dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->error, LOG_ERR);
return -1;
}
$this->db->begin();
$this->fk_account = $accountid;
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
dol_syslog("{$user->id},{$mode},{$label},{$this->fk_account},{$emetteur_nom},{$emetteur_banque}");
$acc = new Account($this->db);
$result = $acc->fetch($this->fk_account);
$totalamount = $this->amount;
if (empty($totalamount)) {
$totalamount = $this->total;
}
// For backward compatibility
if ($mode == 'payment_supplier') {
$totalamount = -$totalamount;
}
// Insert payment into llx_bank
$bank_line_id = $acc->addline($this->datepaye, $this->paiementid, $label, $totalamount, $this->num_paiement, '', $user, $emetteur_nom, $emetteur_banque);
// Mise a jour fk_bank dans llx_paiement
// On connait ainsi le paiement qui a genere l'ecriture bancaire
if ($bank_line_id > 0) {
$result = $this->update_fk_bank($bank_line_id);
if ($result <= 0) {
$error++;
dol_print_error($this->db);
}
// Add link 'payment', 'payment_supplier' in bank_url between payment and bank transaction
if (!$error) {
$url = '';
if ($mode == 'payment') {
$url = DOL_URL_ROOT . '/compta/paiement/card.php?id=';
}
if ($mode == 'payment_supplier') {
$url = DOL_URL_ROOT . '/fourn/paiement/card.php?id=';
}
if ($url) {
$result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
if ($result <= 0) {
$error++;
dol_print_error($this->db);
}
}
}
// Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
if (!$error && $label != '(WithdrawalPayment)') {
$linkaddedforthirdparty = array();
foreach ($this->amounts as $key => $value) {
if ($mode == 'payment') {
$fac = new Facture($this->db);
$fac->fetch($key);
$fac->fetch_thirdparty();
if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) {
$result = $acc->add_url_line($bank_line_id, $fac->thirdparty->id, DOL_URL_ROOT . '/comm/card.php?socid=', $fac->thirdparty->name, 'company');
if ($result <= 0) {
dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->db->lasterror());
}
$linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
// Mark as done for this thirdparty
}
}
if ($mode == 'payment_supplier') {
$fac = new FactureFournisseur($this->db);
$fac->fetch($key);
$fac->fetch_thirdparty();
if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) {
$result = $acc->add_url_line($bank_line_id, $fac->thirdparty->id, DOL_URL_ROOT . '/fourn/card.php?socid=', $fac->thirdparty->name, 'company');
if ($result <= 0) {
dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->db->lasterror());
}
$linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
// Mark as done for this thirdparty
}
}
}
}
if (!$error && !$notrigger) {
// Appel des triggers
$result = $this->call_trigger('PAYMENT_ADD_TO_BANK', $user);
//.........這裏部分代碼省略.........
示例3: Facture
}
print '<input type="hidden" name="email" value="' . $order->thirdparty->email . '">' . "\n";
print '<input type="hidden" name="desc" value="' . $langs->trans("Order") . ' ' . $order->ref . '">' . "\n";
}
// Payment on customer invoice
if (GETPOST("source") == 'invoice' && $valid) {
$found = true;
$langs->load("bills");
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
$invoice = new Facture($db);
$result = $invoice->fetch('', $ref);
if ($result < 0) {
$mesg = $invoice->error;
$error++;
} else {
$result = $invoice->fetch_thirdparty($invoice->socid);
}
$amount = price2num($invoice->total_ttc - $invoice->getSommePaiement());
if (GETPOST("amount", 'int')) {
$amount = GETPOST("amount", 'int');
}
$amount = price2num($amount);
$fulltag = 'INV=' . $invoice->ref . '.CUS=' . $invoice->thirdparty->id;
//$fulltag.='.NAM='.strtr($invoice->thirdparty->name,"-"," ");
if (!empty($TAG)) {
$tag = $TAG;
$fulltag .= '.TAG=' . $TAG;
}
$fulltag = dol_string_unaccent($fulltag);
// Creditor
$var = !$var;
示例4: Facture
print load_fiche_titre($langs->trans("CreateRepeatableInvoice"), '', 'title_accountancy.png');
$object = new Facture($db);
// Source invoice
$product_static = new Product($db);
if ($object->fetch($id) > 0) {
print '<form action="fiche-rec.php" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="facid" value="' . $object->id . '">';
dol_fiche_head();
$rowspan = 4;
if (!empty($conf->projet->enabled) && $object->fk_project > 0) {
$rowspan++;
}
print '<table class="border" width="100%">';
$object->fetch_thirdparty();
// Third party
print '<tr><td>' . $langs->trans("Customer") . '</td><td>' . $object->client->getNomUrl(1, 'customer') . '</td>';
print '<td>';
print $langs->trans("Comment");
print '</td></tr>';
// Title
print '<tr><td class="fieldrequired">' . $langs->trans("Title") . '</td><td>';
print '<input class="flat" type="text" name="titre" size="24" value="' . $_POST["titre"] . '">';
print '</td>';
// Note
print '<td rowspan="' . $rowspan . '" valign="top">';
print '<textarea class="flat" name="note_private" wrap="soft" cols="60" rows="' . ROWS_4 . '"></textarea>';
print '</td></tr>';
// Author
print "<tr><td>" . $langs->trans("Author") . "</td><td>" . $user->getFullName($langs) . "</td></tr>";
示例5: 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;
//.........這裏部分代碼省略.........
示例6: count
function _showLCR($pdf, $object, $outputlangs, &$TtoGenerate)
{
global $db, $conf;
//Gestion LCR /////////////////////////////////////////////////////////////////////
$pdf->AddPage();
$posy = 50;
$pdf->SetDrawColor(0, 0, 0);
$default_font_size = pdf_getPDFFontSize($outputlangs);
$nb_facture = count($TtoGenerate);
foreach ($TtoGenerate as $ii => $ref_piece) {
$f = new Facture($db);
$f->fetch('', $ref_piece);
$f->fetch_thirdparty();
$object =& $f;
if (!empty($conf->global->LCR_USE_REST_TO_PAY)) {
$deja_regle = $object->getSommePaiement();
$creditnoteamount = $object->getSumCreditNotesUsed();
$depositsamount = $object->getSumDepositsUsed();
$resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
} else {
$resteapayer = price2num($object->total_ttc);
}
// ENTETE
if (!empty($conf->global->LCR_GENERATE_ONE_PER_PAGE_WiTH_ADDRESS)) {
$this->_pagehead($pdf, $object, 1, $outputlangs);
$curx = $this->marge_gauche;
$heightforinfotot = 50;
// Height reserved to output the info and total part
$heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5;
// Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8;
// Height reserved to output the footer (value include bottom margin)
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 10;
$cury = $bottomlasttab;
$pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(200, 200, 200)));
$pdf->Line($curx, $cury - 11, $this->page_largeur - $this->marge_droite, $cury - 11);
$pdf->SetLineStyle(array('dash' => 0, 'color' => array(0, 0, 0)));
} else {
$curx = $this->marge_gauche;
$cury = $posy - 30;
}
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(53, 20, 10, $cury - 8, $outputlangs->convToOutputCharset('MERCI DE NOUS RETOURNER LA PRESENTE TRAITE SOUS 8 JOURS.'), 0, 1, false, true, 'J', true);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->writeHTMLCell(40, 20, 70, $cury - 8, $outputlangs->convToOutputCharset('Contre cette LETTRE DE CHANGE STIPULEE SANS FRAIS'), 0, 1, false, true, 'J', true);
$pdf->writeHTMLCell(40, 20, 70, $cury - 3, $outputlangs->convToOutputCharset('Veuillez payer la somme indiquée ci_dessous à l\'ordre de'), 0, 1, false, true, 'J', true);
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->writeHTMLCell(20, 20, 115, $cury - 8, $outputlangs->convToOutputCharset($conf->global->MAIN_INFO_SOCIETE_NOM), 0, 1, false, true, 'J', true);
$pdf->writeHTMLCell(40, 20, 115, $cury - 5, $outputlangs->convToOutputCharset($conf->global->MAIN_INFO_SOCIETE_ADDRESS), 0, 1, false, true, 'J', true);
$pdf->writeHTMLCell(40, 20, 115, $cury + 1, $outputlangs->convToOutputCharset($conf->global->MAIN_INFO_SOCIETE_ZIP . ' ' . $conf->global->MAIN_INFO_SOCIETE_TOWN), 0, 1, false, true, 'J', true);
//Affichage code monnaie
$pdf->SetXY(180, $cury + 1);
$pdf->SetFont(pdf_getPDFFont($outputlangs), '', 7);
$pdf->Cell(18, 0, "Code Monnaie", 0, 1, C);
$pdf->SetXY(180, $cury + 5);
$pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 14);
$pdf->Cell(18, 0, $outputlangs->trans($conf->currency), 0, 0, C);
//Affichage lieu / date
//$town = !empty($this->emetteur->town) ? $this->emetteur->town : $this->emetteur->ville;
$town = $conf->global->MAIN_INFO_SOCIETE_TOWN;
$cury += 5;
$pdf->SetXY(30, $cury);
$pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
$pdf->Cell(15, 0, "A " . $outputlangs->convToOutputCharset($town) . ", le", 0, 1, 'R');
// jolie fleche ...
$curx = 43;
$cury += 2;
$largeur_cadre = 5;
$pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre + 5, $cury);
$pdf->Line($curx + $largeur_cadre + 5, $cury, $curx + $largeur_cadre + 5, $cury + 2);
$pdf->Line($curx + $largeur_cadre + 4, $cury + 2, $curx + $largeur_cadre + 6, $cury + 2);
$pdf->Line($curx + $largeur_cadre + 4, $cury + 2, $curx + $largeur_cadre + 5, $cury + 3);
$pdf->Line($curx + $largeur_cadre + 6, $cury + 2, $curx + $largeur_cadre + 5, $cury + 3);
// fin jolie fleche
//Affichage toute la ligne qui commence par "montant pour controle" ...
$curx = $this->marge_gauche;
$cury += 5;
$hauteur_cadre = 8;
$largeur_cadre = 27;
$pdf->SetXY($curx, $cury);
$pdf->SetFont(pdf_getPDFFont($outputlangs), '', 7);
$pdf->Cell($largeur_cadre, 0, "Montant pour contrôle", 0, 0, C);
$pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
$pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeur_cadre, $cury + $hauteur_cadre);
$pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre, $cury + $hauteur_cadre);
$pdf->SetXY($curx, $cury + 4);
$pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
$pdf->Cell($largeur_cadre, 0, price($resteapayer), 0, 0, C);
$curx = $curx + $largeur_cadre + 5;
$hauteur_cadre = 8;
$largeur_cadre = 25;
$pdf->SetXY($curx, $cury);
$pdf->SetFont(pdf_getPDFFont($outputlangs), '', 7);
$pdf->Cell($largeur_cadre, 0, "Date de création", 0, 0, C);
$pdf->Line($curx, $cury, $curx, $cury + $hauteur_cadre);
$pdf->Line($curx, $cury + $hauteur_cadre, $curx + $largeur_cadre, $cury + $hauteur_cadre);
$pdf->Line($curx + $largeur_cadre, $cury, $curx + $largeur_cadre, $cury + $hauteur_cadre);
$pdf->SetXY($curx, $cury + 4);
$pdf->SetFont(pdf_getPDFFont($outputlangs), 'B', 8);
$pdf->Cell($largeur_cadre, 0, dol_print_date($object->date, "day", false, $outpulangs), 0, 0, C);
//.........這裏部分代碼省略.........
示例7: getFormMail
function getFormMail($parameters, &$object, &$action, $hookmanager)
{
if (in_array('formmail', explode(':', $parameters['context']))) {
if (!empty($object->param['facid'])) {
global $db;
$facture = new Facture($db);
$facture->fetch((int) $object->param['facid']);
//var_dump($facture);
if ($facture->socid > 0) {
if (empty($facture->thirdparty)) {
$facture->fetch_thirdparty();
}
$societe =& $facture->thirdparty;
if (!empty($societe->array_options['options_facture_papier']) && $societe->array_options['options_facture_papier'] == 2) {
?>
<script type="text/javascript">
$(document).ready(function() {
$("<div style=\"color:red;font-weight:bold;\">Attention ce client est paramétré par défaut en courrier</div>").dialog({
modal:true
,title:"Attention !"
,buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
</script><?php
}
}
}
}
return 0;
}
開發者ID:ATM-Consulting,項目名稱:dolibarr_module_facturecourrier,代碼行數:34,代碼來源:actions_facturecourrier.class.php
示例8: _parseNatixis
function _parseNatixis(&$db, &$TRefFacture)
{
global $conf, $langs;
$TError = $TData = array();
$currency = str_pad($conf->currency, 3);
$cptLine = 2;
//cpt à 2 pcq firstLine contient déjà le cpt à 1
// Première ligne du fichier
$firstLine = '01000001138FA053506' . $currency . date('Ymd');
$firstLine .= str_repeat(' ', 22) . 'D';
$firstLine .= str_repeat(' ', 77);
$firstLine .= str_repeat('0', 30);
$firstLine = array($firstLine);
$total = 0;
foreach ($TRefFacture as $ref) {
$facture = new Facture($db);
$facture->fetch('', $ref);
$facture->fetch_thirdparty();
$facnumber = str_replace('-', '', $facture->ref);
if (empty($facture->thirdparty->code_compta)) {
$TError['TErrorCodeCompta'][] = $langs->transnoentitiesnoconv('ErrorFactorEmptyCodeCompta', $facture->ref, $facture->thirdparty->name);
}
if (empty($facture->mode_reglement_code)) {
$TError['TErrorModeReglt'][] = $langs->transnoentitiesnoconv('ErrorFactorEmptyModeReglt', $facture->ref);
}
if ($facture->type == 2) {
$factype = 'AV';
$date_ech = ' ';
$mod = ' ';
} else {
$factype = 'FA';
$date_ech = date('Ymd', $facture->date_lim_reglement);
$mod = $facture->mode_reglement_code;
}
$TData[] = array('04', str_pad($cptLine, 6, 0, STR_PAD_LEFT), '138', $factype, '053506', $currency, '0', substr($facnumber, -7), str_pad($facture->thirdparty->code_compta, 10), str_repeat(' ', 5), date('Ymd', $facture->date), $date_ech, $mod, str_repeat(' ', 66), str_repeat('0', 15), str_pad(round($facture->total_ttc * 100), 15, 0, STR_PAD_LEFT));
$total += round($facture->total_ttc * 100);
$cptLine++;
}
$_SESSION['TErrorCodeCompta'] = $TError['TErrorCodeCompta'];
$_SESSION['TErrorModeReglt'] = $TError['TErrorModeReglt'];
$cptLine = str_pad($cptLine, 6, 0, STR_PAD_LEFT);
// Dernière ligne du fichier
$endLine = '09' . $cptLine . '138FA053506' . $currency . str_repeat(' ', 108);
$endLine .= str_pad(count($TData), 15, 0, STR_PAD_LEFT);
$endLine .= str_pad($total, 15, 0, STR_PAD_LEFT);
$endLine = array($endLine);
// write file
$folder = $conf->entity == 1 ? DOL_DATA_ROOT . '/factor/' : DOL_DATA_ROOT . '/' . $conf->entity . '/factor/';
dol_mkdir($folder);
$fileName = 'export_natixis_' . date('Ymd') . '.txt';
$fullPath = $folder . $fileName;
$handle = fopen($fullPath, 'w');
if ($handle) {
fwrite($handle, implode('', $firstLine) . "\n");
foreach ($TData as &$TInfo) {
fwrite($handle, implode('', $TInfo) . "\n");
}
fwrite($handle, implode('', $endLine) . "\n");
fclose($handle);
return $fileName;
} else {
setEventMessages('ErrorCanNotCreateExportFile', array(), 'errors');
return 0;
}
}
示例9: addPaymentToBank
/**
* A record into bank for payment with links between this bank record and invoices of payment.
* All payment properties must have been set first like after a call to create().
* @param user Object of user making payment
* @param mode 'payment', 'payment_supplier'
* @param label Label to use in bank record
* @param accountid Id of bank account to do link with
* @param emetteur_nom Name of transmitter
* @param emetteur_banque Name of bank
* @return int <0 if KO, bank_line_id if OK
*/
function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque,$notrigger=0)
{
global $conf,$langs,$user;
$error=0;
$bank_line_id=0;
$this->fk_account=$accountid;
if ($conf->banque->enabled)
{
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
dol_syslog("$user->id,$mode,$label,$this->fk_account,$emetteur_nom,$emetteur_banque");
$acc = new Account($this->db);
$acc->fetch($this->fk_account);
$totalamount=$this->amount;
if (empty($totalamount)) $totalamount=$this->total; // For backward compatibility
if ($mode == 'payment') $totalamount=$totalamount;
if ($mode == 'payment_supplier') $totalamount=-$totalamount;
// Insert payment into llx_bank
$bank_line_id = $acc->addline($this->datepaye,
$this->paiementid, // Payment mode id or code ("CHQ or VIR for example")
$label,
$totalamount,
$this->num_paiement,
'',
$user,
$emetteur_nom,
$emetteur_banque);
// Mise a jour fk_bank dans llx_paiement
// On connait ainsi le paiement qui a genere l'ecriture bancaire
if ($bank_line_id > 0)
{
$result=$this->update_fk_bank($bank_line_id);
if ($result <= 0)
{
$error++;
dol_print_error($this->db);
}
// Add link 'payment', 'payment_supplier' in bank_url between payment and bank transaction
if ( ! $error)
{
$url='';
if ($mode == 'payment') $url=DOL_URL_ROOT.'/compta/paiement/fiche.php?id=';
if ($mode == 'payment_supplier') $url=DOL_URL_ROOT.'/fourn/paiement/fiche.php?id=';
if ($url)
{
$result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
if ($result <= 0)
{
$error++;
dol_print_error($this->db);
}
}
}
// Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
if (! $error)
{
$linkaddedforthirdparty=array();
foreach ($this->amounts as $key => $value) // We should have always same third party but we loop in case of.
{
if ($mode == 'payment')
{
$fac = new Facture($this->db);
$fac->fetch($key);
$fac->fetch_thirdparty();
if (! in_array($fac->thirdparty->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty
{
$result=$acc->add_url_line($bank_line_id, $fac->thirdparty->id,
DOL_URL_ROOT.'/comm/fiche.php?socid=', $fac->thirdparty->nom, 'company');
if ($result <= 0) dol_print_error($this->db);
$linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty
}
}
if ($mode == 'payment_supplier')
{
$fac = new FactureFournisseur($this->db);
$fac->fetch($key);
$fac->fetch_thirdparty();
if (! in_array($fac->thirdparty->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty
{
$result=$acc->add_url_line($bank_line_id, $fac->thirdparty->id,
DOL_URL_ROOT.'/fourn/fiche.php?socid=', $fac->thirdparty->nom, 'company');
//.........這裏部分代碼省略.........
示例10: facture_meta_create
/**
* Create a meta file with document file into same directory.
* This should allow rgrep search.
* @param db Objet base de donnee
* @param facid Id de la facture a creer
* @param message Message
*/
function facture_meta_create($db, $facid, $message="")
{
global $langs,$conf;
$fac = new Facture($db,"",$facid);
$fac->fetch($facid);
$fac->fetch_thirdparty();
if ($conf->facture->dir_output)
{
$facref = dol_sanitizeFileName($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref ;
$file = $dir . "/" . $facref . ".meta";
if (! is_dir($dir))
{
create_exdir($dir);
}
if (is_dir($dir))
{
$nblignes = sizeof($fac->lines);
$client = $fac->client->nom . " " . $fac->client->address . " " . $fac->client->cp . " " . $fac->client->ville;
$meta = "REFERENCE=\"" . $fac->ref . "\"
DATE=\"" . dol_print_date($fac->date,'') . "\"
NB_ITEMS=\"" . $nblignes . "\"
CLIENT=\"" . $client . "\"
TOTAL_HT=\"" . $fac->total_ht . "\"
TOTAL_TTC=\"" . $fac->total_ttc . "\"\n";
for ($i = 0 ; $i < $nblignes ; $i++)
{
//Pour les articles
$meta .= "ITEM_" . $i . "_QUANTITY=\"" . $fac->lines[$i]->qty . "\"
ITEM_" . $i . "_UNIT_PRICE=\"" . $fac->lines[$i]->price . "\"
ITEM_" . $i . "_TVA=\"" .$fac->lines[$i]->tva_tx . "\"
ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($fac->lines[$i]->desc)) . "\"
";
}
}
$fp = fopen ($file,"w");
fputs($fp,$meta);
fclose($fp);
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
}
}