本文整理汇总了PHP中Paiement::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Paiement::create方法的具体用法?PHP Paiement::create怎么用?PHP Paiement::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paiement
的用法示例。
在下文中一共展示了Paiement::create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Paiement
* Action confirm_paiement
*/
if ($action == 'confirm_paiement' && $confirm == 'yes') {
$error = 0;
$datepaye = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$db->begin();
// Creation of payment line
$paiement = new Paiement($db);
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts;
// Array with all payments dispatching
$paiement->paiementid = dol_getIdFromCode($db, $_POST['paiementcode'], 'c_paiement');
$paiement->num_paiement = $_POST['num_paiement'];
$paiement->note = $_POST['comment'];
if (!$error) {
$paiement_id = $paiement->create($user, GETPOST('closepaidinvoices') == 'on' ? 1 : 0);
if ($paiement_id < 0) {
$errmsg = $paiement->error;
$error++;
}
}
if (!$error) {
$result = $paiement->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $_POST['accountid'], $_POST['chqemetteur'], $_POST['chqbank']);
if ($result < 0) {
$errmsg = $paiement->error;
$error++;
}
}
if (!$error) {
$db->commit();
// If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card
示例2: 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;
//.........这里部分代码省略.........
示例3: isset
}
$id = $invoice->id;
} else {
$resultcreate = $invoice->create($user, 0, 0);
if ($resultcreate > 0) {
$resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0);
$id = $invoice->id;
// Add the payment
$payment = new Paiement($db);
$payment->datepaye = $now;
$payment->bank_account = $conf_fkaccount;
$payment->amounts[$invoice->id] = $obj_facturation->prixTotalTtc();
$payment->note = $langs->trans("Payment") . ' ' . $langs->trans("Invoice") . ' ' . $obj_facturation->numInvoice();
$payment->paiementid = $invoice->mode_reglement_id;
$payment->num_paiement = '';
$paiement_id = $payment->create($user);
if ($paiement_id > 0) {
if (!$error) {
$result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', '');
if (!$result > 0) {
$errmsg = $paiement->error;
$error++;
}
}
if (!$error) {
if ($invoice->total_ttc == $obj_facturation->prixTotalTtc() && $obj_facturation->getSetPaymentMode() != 'DIFF') {
// We set status to payed
$result = $invoice->set_paid($user);
//print 'eeeee';exit;
}
}
示例4: array
/**
* Set withdrawal to credited status
*
* @param User $user id of user
* @param timestamp $date date of action
* @return int >0 if OK, <0 if KO
*/
function set_infocredit($user, $date)
{
global $conf, $langs;
$error = 0;
if ($this->_fetched == 1) {
if ($date >= $this->date_trans) {
if ($this->db->begin()) {
$sql = " UPDATE " . MAIN_DB_PREFIX . "prelevement_bons ";
$sql .= " SET fk_user_credit = " . $user->id;
$sql .= ", statut = 2";
$sql .= ", date_credit = '" . $this->db->idate($date) . "'";
$sql .= " WHERE rowid=" . $this->id;
$sql .= " AND entity = " . $conf->entity;
$sql .= " AND statut = 1";
if ($this->db->query($sql)) {
$langs->load('withdrawals');
$subject = $langs->trans("InfoCreditSubject", $this->ref);
$message = $langs->trans("InfoCreditMessage", $this->ref, dol_print_date($date, 'dayhour'));
//Add payment of withdrawal into bank
$bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT;
$facs = array();
$amounts = array();
$facs = $this->getListInvoices(1);
$num = count($facs);
for ($i = 0; $i < $num; $i++) {
$fac = new Facture($this->db);
$fac->fetch($facs[$i][0]);
$amounts[$fac->id] = $facs[$i][1];
$result = $fac->set_paid($user);
}
$paiement = new Paiement($this->db);
$paiement->datepaye = $date;
$paiement->amounts = $amounts;
$paiement->paiementid = 3;
//
$paiement->num_paiement = $this->ref;
$paiement_id = $paiement->create($user);
if ($paiement_id < 0) {
dol_syslog(get_class($this) . "::set_credite AddPayment Error");
$error++;
} else {
$result = $paiement->addPaymentToBank($user, 'payment', '(WithdrawalPayment)', $bankaccount, '', '');
if ($result < 0) {
dol_syslog(get_class($this) . "::set_credite AddPaymentToBank Error");
$error++;
}
}
// Update prelevement line
// TODO: Translate to ligneprelevement.class.php
$sql = " UPDATE " . MAIN_DB_PREFIX . "prelevement_lignes";
$sql .= " SET statut = 2";
$sql .= " WHERE fk_prelevement_bons = " . $this->id;
if (!$this->db->query($sql)) {
dol_syslog(get_class($this) . "::set_credite Update lines Error");
$error++;
}
} else {
dol_syslog(get_class($this) . "::set_infocredit Update Bons Error");
$error++;
}
/*
* End of procedure
*/
if ($error == 0) {
$this->db->commit();
return 0;
} else {
$this->db->rollback();
dol_syslog("bon-prelevment::set_infocredit ROLLBACK ");
return -1;
}
} else {
dol_syslog(get_class($this) . "::set_infocredit 1025 Open SQL transaction impossible ");
return -1025;
}
} else {
dol_syslog("bon-prelevment::set_infocredit 1027 Date de credit < Date de trans ");
return -1027;
}
} else {
return -1026;
}
}
示例5: create
/**
* Create
*
* @param User $user User object
* @param int $id Id
* @param string $motif Motif
* @param int $date_rejet Date rejet
* @param int $bonid Bon id
* @param int $facturation Facturation
* @return void
*/
function create($user, $id, $motif, $date_rejet, $bonid, $facturation = 0)
{
global $langs, $conf;
$error = 0;
$this->id = $id;
$this->bon_id = $bonid;
$now = dol_now();
dol_syslog("RejetPrelevement::Create id {$id}");
$bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT;
$facs = $this->getListInvoices(1);
$this->db->begin();
// Insert refused line into database
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "prelevement_rejet (";
$sql .= "fk_prelevement_lignes";
$sql .= ", date_rejet";
$sql .= ", motif";
$sql .= ", fk_user_creation";
$sql .= ", date_creation";
$sql .= ", afacturer";
$sql .= ") VALUES (";
$sql .= $id;
$sql .= ", '" . $this->db->idate($date_rejet) . "'";
$sql .= ", " . $motif;
$sql .= ", " . $user->id;
$sql .= ", '" . $this->db->idate($now) . "'";
$sql .= ", " . $facturation;
$sql .= ")";
$result = $this->db->query($sql);
if (!$result) {
dol_syslog("RejetPrelevement::create Erreur 4");
dol_syslog("RejetPrelevement::create Erreur 4 {$sql}");
$error++;
}
// Tag the line to refused
$sql = " UPDATE " . MAIN_DB_PREFIX . "prelevement_lignes ";
$sql .= " SET statut = 3";
$sql .= " WHERE rowid = " . $id;
if (!$this->db->query($sql)) {
dol_syslog("RejetPrelevement::create Erreur 5");
$error++;
}
$num = count($facs);
for ($i = 0; $i < $num; $i++) {
$fac = new Facture($this->db);
$fac->fetch($facs[$i][0]);
// Make a negative payment
$pai = new Paiement($this->db);
$pai->amounts = array();
/*
* We replace the comma with a point otherwise some
* PHP installs sends only the part integer negative
*/
$pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * -1);
$pai->datepaye = $date_rejet;
$pai->paiementid = 3;
// type of payment: withdrawal
$pai->num_paiement = $fac->ref;
if ($pai->create($this->user) < 0) {
$error++;
dol_syslog("RejetPrelevement::Create Error creation payment invoice " . $facs[$i][0]);
} else {
$result = $pai->addPaymentToBank($user, 'payment', '(InvoiceRefused)', $bankaccount, '', '');
if ($result < 0) {
dol_syslog("RejetPrelevement::Create AddPaymentToBan Error");
$error++;
}
// Payment validation
if ($pai->valide() < 0) {
$error++;
dol_syslog("RejetPrelevement::Create Error payment validation");
}
}
//Tag invoice as unpaid
dol_syslog("RejetPrelevement::Create set_unpaid fac " . $fac->ref);
$fac->set_unpaid($user);
//TODO: Must be managed by notifications module
// Send email to sender of the standing order request
$this->_send_email($fac);
}
if ($error == 0) {
dol_syslog("RejetPrelevement::Create Commit");
$this->db->commit();
} else {
dol_syslog("RejetPrelevement::Create Rollback");
$this->db->rollback();
}
}
示例6: Paiement
}
$payment = new Paiement($db);
$payment->datepaye = $now;
if ($facture->mode_reglement_id == 1) {
$fk_bank = $rowterminal[3];
} else {
$fk_bank = $rowterminal[1];
}
$payment->bank_account = $fk_bank;
$payment->amounts[$facture->id] = $facture->total_ttc;
$payment->paiementid = $facture->mode_reglement_id;
if ($payment->paiementid == 5) {
$payment->paiementid = 4;
}
$payment->num_paiement = '';
$payment_id = $payment->create($userpos, 1);
$id = $payment->addPaymentToBank($userpos, 'payment', 'Dolipos', $fk_bank, '', '');
$facture->set_paid($userpos);
$sql = "SELECT * FROM " . MAIN_DB_PREFIX . "facture order by rowid DESC limit 0,1";
$resql = $db->query($sql);
$row = $db->fetch_array($resql);
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "pos_facture values ('',{$terminal},NULL,{$row['0']},NULL,NULL)";
$db->query($sql);
}
if ($action == "delete") {
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
$object = new Facturesim($db);
$object->fetch($id);
$object->set_unpaid('admin');
$sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,';
示例7: rejectCheck
/**
* Check return management
* Reopen linked invoices and create a new negative payment.
*
* @param int $bank_id Id of bank transaction line concerned
* @param date $rejection_date Date to use on the negative payment
* @return int Id of negative payment line created
*/
function rejectCheck($bank_id, $rejection_date)
{
global $db, $user;
$payment = new Paiement($db);
$payment->fetch(0, 0, $bank_id);
$bankline = new AccountLine($db);
$bankline->fetch($bank_id);
/* Conciliation is allowed because when check is returned, a new line is created onto bank transaction log.
if ($bankline->rappro)
{
$this->error='ActionRefusedLineAlreadyConciliated';
return -1;
}*/
$this->db->begin();
// Not conciliated, we can delete it
//$bankline->delete($user); // We delete
$bankaccount = $payment->fk_account;
// Get invoices list to reopen them
$sql = 'SELECT pf.fk_facture, pf.amount';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf';
$sql .= ' WHERE pf.fk_paiement = ' . $payment->id;
$resql = $db->query($sql);
if ($resql) {
$rejectedPayment = new Paiement($db);
$rejectedPayment->amounts = array();
$rejectedPayment->datepaye = $rejection_date;
$rejectedPayment->paiementid = dol_getIdFromCode($this->db, 'CHQ', 'c_paiement');
$rejectedPayment->num_paiement = $payment->numero;
while ($obj = $db->fetch_object($resql)) {
$invoice = new Facture($db);
$invoice->fetch($obj->fk_facture);
$invoice->set_unpaid($user);
$rejectedPayment->amounts[$obj->fk_facture] = price2num($obj->amount) * -1;
}
$result = $rejectedPayment->create($user);
if ($result > 0) {
// We created a negative payment, we also add the line as bank transaction
$result = $rejectedPayment->addPaymentToBank($user, 'payment', '(CheckRejected)', $bankaccount, '', '');
if ($result > 0) {
$result = $payment->reject();
if ($result > 0) {
$this->db->commit();
return $rejectedPayment->id;
} else {
$this->db->rollback();
return -1;
}
} else {
$this->error = $rejectedPayment->error;
$this->errors = $rejectedPayment->errors;
$this->db->rollback();
return -1;
}
} else {
$this->error = $rejectedPayment->error;
$this->errors = $rejectedPayment->errors;
$this->db->rollback();
return -1;
}
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
}
示例8: _setPayment
function _setPayment($user, $db, $conf, $langs)
{
$TPayment = GETPOST('payment', 'array');
$fk_bank = GETPOST('fk_bank', 'int');
if (empty($fk_bank)) {
if (function_exists('setEventMessages')) {
setEventMessages($langs->transnoentitiesnoconv('ErrorPaymentImportNoBankSelected'), array(), 'errors');
} else {
setEventMessage($langs->transnoentitiesnoconv('ErrorPaymentImportNoBankSelected'), 'errors');
}
return;
}
$mode_reglement = GETPOST('paiementcode', 'alpha');
$TFactureNotFound = $TPaimentError = $TWriteBankFail = array();
$nb_facture_not_found = $nb_payment = $nb_writebank = 0;
foreach ($TPayment as $TInfoPayment) {
$facture_ref = trim($TInfoPayment['facture_ref']);
$rib = trim($TInfoPayment['rib']);
$amount = price2num($TInfoPayment['amount']);
$date_creation = trim($TInfoPayment['date_creation']);
$num_payment = trim($TInfoPayment['num_payment']);
$note = trim($TInfoPayment['note']);
if ($amount <= 0) {
continue;
}
$facture = new Facture($db);
if ($facture->fetch(null, $facture_ref) > 0) {
if ($facture->paye) {
$TFactureAlreadyPaid[] = $langs->transnoentitiesnoconv('paymentimport_warningFactureAlreadyPaid', $facture_ref);
continue;
// Sécurité si jamais la facture est déjà payé on ne saisie pas de nouveau règlement
}
if (!empty($conf->global->PAYMENTIMPORT_FORCE_DATE_TODAY)) {
$datepaye = dol_mktime(date('H'), date('m'), date('s'), date('m'), date('d'), date('Y'));
} else {
$date_creation = explode('/', $date_creation);
$datepaye = dol_mktime(12, 0, 0, $date_creation[1], $date_creation[0], $date_creation[2]);
}
if (empty($mode_reglement)) {
$paiementcode = $facture->mode_reglement_code;
} else {
$paiementcode = $mode_reglement;
}
// Creation of payment line
$paiement = new Paiement($db);
$paiement->datepaye = $datepaye;
$paiement->amounts = array($facture->id => $amount);
// Array with all payments dispatching
$paiement->paiementid = dol_getIdFromCode($db, $paiementcode, 'c_paiement');
$paiement->num_paiement = $num_payment;
$paiement->note = $note;
$paiement_id = $paiement->create($user, 1);
if ($paiement_id > 0) {
$nb_payment++;
$label = '(CustomerInvoicePayment)';
$result = $paiement->addPaymentToBank($user, 'payment', $label, $fk_bank, '', '');
if ($result > 0) {
$nb_writebank++;
} else {
$TWriteBankFail[] = $langs->transnoentitiesnoconv('paymentimport_errorwritebank', $facture_ref);
}
} else {
$TPaimentError[] = $langs->transnoentitiesnoconv('paymentimport_errorpayment', $facture_ref, $rib, $amount);
}
} else {
$TFactureNotFound[] = $langs->transnoentitiesnoconv('paymentimport_errorfactnotfound', $facture_ref);
$nb_facture_not_found++;
}
}
if ($nb_facture_not_found > 0) {
if (function_exists('setEventMessages')) {
setEventMessages($langs->trans('paymentimport_nb_facture_not_found', $nb_facture_not_found), array(), 'errors');
} else {
setEventMessage($langs->trans('paymentimport_nb_facture_not_found', $nb_facture_not_found), 'errors');
}
}
if ($nb_payment > 0) {
if (function_exists('setEventMessages')) {
setEventMessages($langs->trans('paymentimport_nb_payment', $nb_payment), array());
} else {
setEventMessage($langs->trans('paymentimport_nb_payment', $nb_payment));
}
}
if ($nb_writebank > 0) {
if (function_exists('setEventMessages')) {
setEventMessages($langs->trans('paymentimport_nb_writebank', $nb_writebank), array());
} else {
setEventMessage($langs->trans('paymentimport_nb_writebank', $nb_writebank));
}
}
$_SESSION['TFactureNotFound'] = $TFactureNotFound;
$_SESSION['TPaimentError'] = $TPaimentError;
$_SESSION['TWriteBankFail'] = $TWriteBankFail;
$_SESSION['TFactureAlreadyPaid'] = $TFactureAlreadyPaid;
}