本文整理汇总了PHP中FactureFournisseur::getSommePaiement方法的典型用法代码示例。如果您正苦于以下问题:PHP FactureFournisseur::getSommePaiement方法的具体用法?PHP FactureFournisseur::getSommePaiement怎么用?PHP FactureFournisseur::getSommePaiement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FactureFournisseur
的用法示例。
在下文中一共展示了FactureFournisseur::getSommePaiement方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadBox
/**
* Load data into info_box_contents array to show array later.
*
* @param int $max Maximum number of records to load
* @return void
*/
function loadBox($max = 5)
{
global $conf, $user, $langs, $db;
$this->max = $max;
include_once DOL_DOCUMENT_ROOT . "/fourn/class/fournisseur.facture.class.php";
$facturestatic = new FactureFournisseur($db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastSupplierBills", $max));
if ($user->rights->fournisseur->facture->lire) {
$sql = "SELECT s.nom, s.rowid as socid,";
$sql .= " f.rowid as facid, f.facnumber, f.amount,";
$sql .= " f.paye, f.fk_statut,";
$sql .= ' f.datef as df,';
$sql .= ' f.datec as datec,';
$sql .= ' f.date_lim_reglement as datelimite, f.tms, f.type';
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "facture_fourn as f";
if (!$user->rights->societe->client->voir && !$user->societe_id) {
$sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity = " . $conf->entity;
if (!$user->rights->societe->client->voir && !$user->societe_id) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
}
if ($user->societe_id) {
$sql .= " AND s.rowid = " . $user->societe_id;
}
$sql .= " ORDER BY f.tms DESC";
$sql .= $db->plimit($max, 0);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$now = dol_now();
$i = 0;
$l_due_date = $langs->trans('Late') . ' (' . strtolower($langs->trans('DateEcheance')) . ': %s)';
while ($i < $num) {
$objp = $db->fetch_object($result);
$datelimite = $db->jdate($objp->datelimite);
$datec = $db->jdate($objp->datec);
$late = '';
if ($objp->paye == 0 && $datelimite < $now - $conf->facture->fournisseur->warning_delay) {
$late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day')));
}
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/fourn/facture/fiche.php?facid=" . $objp->facid);
$this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->facnumber, 'text2' => $late, 'url' => DOL_URL_ROOT . "/fourn/facture/fiche.php?facid=" . $objp->facid);
$this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/fourn/fiche.php?socid=" . $objp->socid);
$this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => $objp->nom, 'url' => DOL_URL_ROOT . "/fourn/fiche.php?socid=" . $objp->socid);
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datec, 'day'));
$fac = new FactureFournisseur($db);
$fac->fetch($objp->facid);
$alreadypaid = $fac->getSommePaiement();
$this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type));
$i++;
}
if ($num == 0) {
$this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoModifiedSupplierBills"));
}
} else {
dol_print_error($db);
}
} else {
$this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->transnoentities("ReadPermissionNotAllowed"));
}
}
示例2: create
/**
* Create payment in database
*
* @param User $user Object of creating user
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @return int id of created payment, < 0 if error
*/
function create($user, $closepaidinvoices = 0)
{
global $langs, $conf;
$error = 0;
// Clean parameters
$this->total = 0;
foreach ($this->amounts as $key => $value) {
$newvalue = price2num($value, 'MT');
$this->amounts[$key] = $newvalue;
$this->total += $newvalue;
}
$this->total = price2num($this->total);
$this->db->begin();
if ($this->total != 0) {
$now = dol_now();
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'paiementfourn (';
$sql .= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)';
$sql .= " VALUES ('" . $this->db->idate($now) . "',";
$sql .= " '" . $this->db->idate($this->datepaye) . "', '" . $this->total . "', " . $this->paiementid . ", '" . $this->num_paiement . "', '" . $this->db->escape($this->note) . "', " . $user->id . ", 0)";
dol_syslog("PaiementFourn::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . 'paiementfourn');
// Insere tableau des montants / factures
foreach ($this->amounts as $key => $amount) {
$facid = $key;
if (is_numeric($amount) && $amount != 0) {
$amount = price2num($amount);
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount)';
$sql .= ' VALUES (' . $facid . ',' . $this->id . ',\'' . $amount . '\')';
$resql = $this->db->query($sql);
if ($resql) {
// If we want to closed payed invoices
if ($closepaidinvoices) {
$invoice = new FactureFournisseur($this->db);
$invoice->fetch($facid);
$paiement = $invoice->getSommePaiement();
//$creditnotes=$invoice->getSumCreditNotesUsed();
$creditnotes = 0;
//$deposits=$invoice->getSumDepositsUsed();
$deposits = 0;
$alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
$remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
if ($remaintopay == 0) {
$result = $invoice->set_paid($user, '', '');
} else {
dol_syslog("Remain to pay for invoice " . $facid . " not null. We do nothing.");
}
}
} else {
dol_syslog('Paiement::Create Erreur INSERT dans paiement_facture ' . $facid);
$error++;
}
} else {
dol_syslog('PaiementFourn::Create Montant non numerique', LOG_ERR);
}
}
if (!$error) {
// Call trigger
$result = $this->call_trigger('PAYMENT_SUPPLIER_CREATE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
} else {
$this->error = $this->db->lasterror();
$error++;
}
} else {
$this->error = "ErrorTotalIsNull";
dol_syslog('PaiementFourn::Create Error ' . $this->error, LOG_ERR);
$error++;
}
if ($this->total != 0 && $error == 0) {
$this->db->commit();
dol_syslog('PaiementFourn::Create Ok Total = ' . $this->total);
return $this->id;
} else {
$this->db->rollback();
return -1;
}
}
示例3:
//$obj = $db->fetch_object($result);
$obj = array_shift($tab_sqlobj);
if ($obj->family == 'invoice_supplier') {
$showline = 1;
// Uncomment this line to avoid to count suppliers credit note (ff.type = 2)
//$showline=(($obj->total_ttc < 0 && $obj->type != 2) || ($obj->total_ttc > 0 && $obj->type == 2))
if ($showline) {
$ref = $obj->ref;
$facturefournstatic->ref = $ref;
$facturefournstatic->id = $obj->objid;
$facturefournstatic->type = $obj->type;
$ref = $facturefournstatic->getNomUrl(1, '');
$societestatic->id = $obj->socid;
$societestatic->name = $obj->name;
$refcomp = $societestatic->getNomUrl(1, '', 24);
$paiement = -1 * $facturefournstatic->getSommePaiement();
// Payment already done
}
}
if ($obj->family == 'invoice') {
$facturestatic->ref = $obj->ref;
$facturestatic->id = $obj->objid;
$facturestatic->type = $obj->type;
$ref = $facturestatic->getNomUrl(1, '');
$societestatic->id = $obj->socid;
$societestatic->name = $obj->name;
$refcomp = $societestatic->getNomUrl(1, '', 24);
$paiement = $facturestatic->getSommePaiement();
// Payment already done
}
if ($obj->family == 'social_contribution') {
示例4: FactureFournisseur
print '<td> </td>';
print '</tr>';
if (!$num > 0) {
print '<tr><td colspan="7">' . $langs->trans("NoInvoice") . '</td></tr>';
}
$solde = 0;
// Boucle sur chaque facture
for ($i = 0; $i < $num; $i++) {
$objf = $db->fetch_object($resql);
$fac = new FactureFournisseur($db);
$ret = $fac->fetch($objf->facid);
if ($ret < 0) {
print $fac->error . "<br>";
continue;
}
$totalpaye = $fac->getSommePaiement();
$var = !$var;
print "<tr {$bc[$var]}>";
print "<td align=\"center\">" . dol_print_date($fac->date) . "</td>\n";
print "<td><a href=\"facture/fiche.php?facid={$fac->id}\">" . img_object($langs->trans("ShowBill"), "bill") . " " . $fac->ref . "</a></td>\n";
print '<td aling="left">' . $fac->getLibStatut(2, $totalpaye) . '</td>';
print '<td align="right">' . price($fac->total_ttc) . "</td>\n";
$solde = $solde + $fac->total_ttc;
print '<td align="right"> </td>';
print '<td align="right">' . price($solde) . "</td>\n";
// Author
print '<td nowrap="nowrap" width="50"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $objf->userid . '">' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $objf->login . '</a></td>';
print "</tr>\n";
// Payments
$sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
$sql .= " p.fk_user_author, u.login, u.rowid as userid";
示例5: count
/**
* Function to build pdf onto disk
*
* @param FactureFournisseur $object Id of object to generate
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @return int 1=OK, 0=KO
*/
function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $user, $langs, $conf, $mysoc, $hookmanager;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("products");
if ($conf->fournisseur->dir_output . '/facture') {
$object->fetch_thirdparty();
$deja_regle = $object->getSommePaiement();
//$amount_credit_notes_included = $object->getSumCreditNotesUsed();
//$amount_deposits_included = $object->getSumDepositsUsed();
// Definition of $dir and $file
if ($object->specimen) {
$dir = $conf->fournisseur->facture->dir_output;
$file = $dir . "/SPECIMEN.pdf";
} else {
$objectref = dol_sanitizeFileName($object->ref);
$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
$dir = $conf->fournisseur->facture->dir_output . '/' . get_exdir($object->id, 2) . $objectref;
$file = $dir . "/" . $objectref . ".pdf";
if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) {
$file = $dir . "/" . $objectref . ($objectrefsupplier ? "_" . $objectrefsupplier : "") . ".pdf";
}
}
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
if (file_exists($dir)) {
$nblignes = count($object->lines);
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
// Must be after pdf_getInstance
$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)
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
$pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Invoice"));
$pdf->SetCreator("Dolibarr " . DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Order"));
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
$pdf->SetCompression(false);
}
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
// Left, Top, Right
// Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0; $i < $nblignes; $i++) {
if ($object->lines[$i]->remise_percent) {
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount)) {
$this->posxpicture += $this->postotalht - $this->posxdiscount;
$this->posxtva += $this->postotalht - $this->posxdiscount;
$this->posxup += $this->postotalht - $this->posxdiscount;
$this->posxqty += $this->postotalht - $this->posxdiscount;
$this->posxdiscount += $this->postotalht - $this->posxdiscount;
//$this->postotalht;
}
// New page
//.........这里部分代码省略.........
示例6: loadBox
/**
* Load data into info_box_contents array to show array later.
*
* @param int $max Maximum number of records to load
* @return void
*/
function loadBox($max = 5)
{
global $conf, $user, $langs, $db;
$this->max = $max;
include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php';
$facturestatic = new FactureFournisseur($db);
$thirdpartytmp = new Fournisseur($db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleLast" . ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified") . "SupplierBills", $max));
if ($user->rights->fournisseur->facture->lire) {
$sql = "SELECT s.nom as name, s.rowid as socid,";
$sql .= " s.code_fournisseur,";
$sql .= " s.logo,";
$sql .= " f.rowid as facid, f.ref, f.ref_supplier,";
$sql .= " f.total_ht,";
$sql .= " f.total_tva,";
$sql .= " f.total_ttc,";
$sql .= " f.paye, f.fk_statut,";
$sql .= ' f.datef as df,';
$sql .= ' f.datec as datec,';
$sql .= ' f.date_lim_reglement as datelimite, f.tms, f.type';
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "facture_fourn as f";
if (!$user->rights->societe->client->voir && !$user->societe_id) {
$sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity = " . $conf->entity;
if (!$user->rights->societe->client->voir && !$user->societe_id) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
}
if ($user->societe_id) {
$sql .= " AND s.rowid = " . $user->societe_id;
}
if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) {
$sql .= " ORDER BY f.datef DESC, f.ref DESC ";
} else {
$sql .= " ORDER BY f.tms DESC, f.ref DESC ";
}
$sql .= $db->plimit($max, 0);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$now = dol_now();
$line = 0;
$l_due_date = $langs->trans('Late') . ' (' . $langs->trans('DateEcheance') . ': %s)';
while ($line < $num) {
$objp = $db->fetch_object($result);
$datelimite = $db->jdate($objp->datelimite);
$date = $db->jdate($objp->df);
$datem = $db->jdate($objp->tms);
$facturestatic->id = $objp->facid;
$facturestatic->ref = $objp->ref;
$facturestatic->total_ht = $objp->total_ht;
$facturestatic->total_tva = $objp->total_tva;
$facturestatic->total_ttc = $objp->total_ttc;
$thirdpartytmp->id = $objp->socid;
$thirdpartytmp->name = $objp->name;
$thirdpartytmp->fournisseur = 1;
$thirdpartytmp->code_fournisseur = $objp->code_fournisseur;
$thirdpartytmp->logo = $objp->logo;
$late = '';
if ($objp->paye == 0 && $datelimite && $datelimite < $now - $conf->facture->fournisseur->warning_delay) {
$late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day')));
}
$this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $facturestatic->getNomUrl(1), 'text2' => $late, 'asis' => 1);
$this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $objp->ref_supplier, 'tooltip' => $langs->trans('SupplierInvoice') . ': ' . ($objp->ref ? $objp->ref : $objp->facid) . '<br>' . $langs->trans('RefSupplier') . ': ' . $objp->ref_supplier, 'url' => DOL_URL_ROOT . "/fourn/facture/card.php?facid=" . $objp->facid);
$this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $thirdpartytmp->getNomUrl(1, 'supplier'), 'asis' => 1);
$this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency));
$this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => dol_print_date($date, 'day'));
$fac = new FactureFournisseur($db);
$fac->fetch($objp->facid);
$alreadypaid = $fac->getSommePaiement();
$this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type));
$line++;
}
if ($num == 0) {
$this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoModifiedSupplierBills"));
}
$db->free($result);
} else {
$this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql);
}
} else {
$this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->transnoentities("ReadPermissionNotAllowed"));
}
}
示例7: FactureFournisseur
$atleastonepaymentnotnull = 0;
// Generate payment array and check if there is payment higher than invoice and payment date before invoice date
$tmpinvoice = new FactureFournisseur($db);
foreach ($_POST as $key => $value) {
if (substr($key, 0, 7) == 'amount_') {
$cursorfacid = substr($key, 7);
$amounts[$cursorfacid] = price2num(trim(GETPOST($key)));
$totalpayment = $totalpayment + $amounts[$cursorfacid];
if (!empty($amounts[$cursorfacid])) {
$atleastonepaymentnotnull++;
}
$result = $tmpinvoice->fetch($cursorfacid);
if ($result <= 0) {
dol_print_error($db);
}
$amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
if ($amounts[$cursorfacid]) {
// Check amount
if ($amounts[$cursorfacid] && abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid])) {
$addwarning = 1;
$formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")) . ' ' . $langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
}
// Check date
if ($datepaye && $datepaye < $tmpinvoice->date) {
$langs->load("errors");
//$error++;
setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings');
}
}
$formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]);
}
示例8: unset
unset($_POST['tva_tx']);
unset($_POST['label']);
unset($localtax1_tx);
unset($localtax2_tx);
} else {
if (empty($mesg)) {
$mesg = '<div class="error">' . $object->error . '</div>';
}
}
$action = '';
} elseif ($action == 'classin') {
$object->fetch($id);
$result = $object->setProject($_POST['projectid']);
} elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer) {
$object->fetch($id);
$totalpaye = $object->getSommePaiement();
$resteapayer = $object->total_ttc - $totalpaye;
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
//$ventilExportCompta = $object->getVentilExportCompta();
// On verifie si aucun paiement n'a ete effectue
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) {
$object->set_draft($user);
$outputlangs = $langs;
if (!empty($_REQUEST['lang_id'])) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
//if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
$action = '';
}
} elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer) {
示例9:
{
// TODO This code is to avoid to count suppliers credit note (ff.type = 2)
// Ajouter gestion des avoirs fournisseurs, champ
if (($obj->total_ttc < 0 && $obj->type != 2)
|| ($obj->total_ttc > 0 && $obj->type == 2))
{
$facturefournstatic->ref=$obj->ref;
$facturefournstatic->id=$obj->objid;
$facturefournstatic->type=$obj->type;
$ref = $facturefournstatic->getNomUrl(1,'');
$societestatic->id = $obj->socid;
$societestatic->nom = $obj->nom;
$refcomp=$societestatic->getNomUrl(1,'',24);
$paiement = -1*$facturefournstatic->getSommePaiement(); // Payment already done
}
}
if ($obj->family == 'invoice')
{
$facturestatic->ref=$obj->ref;
$facturestatic->id=$obj->objid;
$facturestatic->type=$obj->type;
$ref = $facturestatic->getNomUrl(1,'');
$societestatic->id = $obj->socid;
$societestatic->nom = $obj->nom;
$refcomp=$societestatic->getNomUrl(1,'',24);
$paiement = $facturestatic->getSommePaiement(); // Payment already done
}
示例10: create
/**
* Create payment in database
* @param user Object of creating user
* @param closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @return int id of created payment, < 0 if error
*/
function create($user,$closepaidinvoices=0)
{
global $langs,$conf;
$error = 0;
// Clean parameters
$this->total = 0;
foreach ($this->amounts as $key => $value)
{
$value = price2num($value);
$val = round($value, 2);
$this->amounts[$key] = $val;
$this->total += $val;
}
$this->total = price2num($this->total);
$this->db->begin();
if ($this->total <> 0) // On accepte les montants negatifs
{
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (';
$sql.= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)';
$sql.= ' VALUES ('.$this->db->idate(mktime()).',';
$sql.= " ".$this->db->idate($this->datepaye).", '".$this->total."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.", 0)";
dol_syslog("PaiementFourn::create sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'paiementfourn');
// Insere tableau des montants / factures
foreach ($this->amounts as $key => $amount)
{
$facid = $key;
if (is_numeric($amount) && $amount <> 0)
{
$amount = price2num($amount);
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount)';
$sql .= ' VALUES ('.$facid.','. $this->id.',\''.$amount.'\')';
$resql=$this->db->query($sql);
if ($resql)
{
// If we want to closed payed invoices
if ($closepaidinvoices)
{
$invoice=new FactureFournisseur($this->db);
$invoice->fetch($facid);
$paiement = $invoice->getSommePaiement();
//$creditnotes=$invoice->getSumCreditNotesUsed();
$creditnotes=0;
//$deposits=$invoice->getSumDepositsUsed();
$deposits=0;
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
if ($remaintopay == 0)
{
$result=$invoice->set_paid($user,'','');
}
else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing.");
}
}
else
{
dol_syslog('Paiement::Create Erreur INSERT dans paiement_facture '.$facid);
$error++;
}
}
else
{
dol_syslog('PaiementFourn::Create Montant non numerique',LOG_ERR);
}
}
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('PAYMENT_SUPPLIER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
}
else
{
$this->error=$this->db->lasterror();
dol_syslog('PaiementFourn::Create Error '.$this->error, LOG_ERR);
$error++;
}
}
//.........这里部分代码省略.........