当前位置: 首页>>代码示例>>PHP>>正文


PHP Paiement::addPaymentToBank方法代码示例

本文整理汇总了PHP中Paiement::addPaymentToBank方法的典型用法代码示例。如果您正苦于以下问题:PHP Paiement::addPaymentToBank方法的具体用法?PHP Paiement::addPaymentToBank怎么用?PHP Paiement::addPaymentToBank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Paiement的用法示例。


在下文中一共展示了Paiement::addPaymentToBank方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isset

 $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;
             }
         }
     } else {
         $error++;
     }
开发者ID:nrjacker4,项目名称:crm-php,代码行数:31,代码来源:validation_verif.php

示例2: Paiement

 $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
     $invoiceid = 0;
     foreach ($paiement->amounts as $key => $amount) {
         $facid = $key;
         if (is_numeric($amount) && $amount != 0) {
             if ($invoiceid != 0) {
                 $invoiceid = -1;
             } else {
开发者ID:netors,项目名称:dolibarr,代码行数:31,代码来源:paiement.php

示例3: setEventMessages

 $paiement->amounts = $amounts;
 $paiement->paiementid = dol_getIdFromCode($db, $operation, 'c_paiement');
 $paiement->num_paiement = $num_chq;
 $paiement->note = $label;
 if (!$error) {
     // Create payment line for invoice
     $paiement_id = $paiement->create($user);
     if (!$paiement_id > 0) {
         $errmsg = $paiement->error;
         $errmsgs = $paiement->errors;
         $error++;
     }
 }
 if (!$error) {
     // Add transaction into bank account
     $bank_line_id = $paiement->addPaymentToBank($user, 'payment', '(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
     if (!($bank_line_id > 0)) {
         $errmsg = $paiement->error;
         $errmsgs = $paiement->errors;
         setEventMessages($paiement->error, $paiement->errors, 'errors');
         $error++;
     }
 }
 if (!$error) {
     // Update fk_bank into subscription table
     $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'cotisation SET fk_bank=' . $bank_line_id;
     $sql .= ' WHERE rowid=' . $crowid;
     $result = $db->query($sql);
     if (!$result) {
         $error++;
     }
开发者ID:Albertopf,项目名称:prueba,代码行数:31,代码来源:card_subscriptions.php

示例4: GETPOST

 $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) {
         setEventMessage($paiement->error, 'errors');
         $error++;
     }
 }
 if (!$error) {
     $label = '(CustomerInvoicePayment)';
     if (GETPOST('type') == 2) {
         $label = '(CustomerInvoicePaymentBack)';
     }
     $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank'));
     if ($result < 0) {
         setEventMessage($paiement->error, 'errors');
         $error++;
     }
 }
 if (!$error) {
     $db->commit();
     // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card
     $invoiceid = 0;
     foreach ($paiement->amounts as $key => $amount) {
         $facid = $key;
         if (is_numeric($amount) && $amount != 0) {
             if ($invoiceid != 0) {
                 $invoiceid = -1;
             } else {
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:31,代码来源:paiement.php

示例5: 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;
     }
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:90,代码来源:bonprelevement.class.php

示例6: addPaymentFac


//.........这里部分代码省略.........
                 $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;
             $modepay[1] = $cash->fk_modepaycash;
             $amount[1] = $aryTicket['customerpay1'] + ($aryTicket['difpayment'] < 0 ? $aryTicket['difpayment'] : 0);
         }
         if ($aryTicket['customerpay2'] != 0) {
             $bankaccountid[2] = $cash->fk_paybank;
             $modepay[2] = $cash->fk_modepaybank;
             $amount[2] = $aryTicket['customerpay2'];
         }
         if ($aryTicket['customerpay3'] != 0) {
             $bankaccountid[3] = $cash->fk_paybank_extra;
             $modepay[3] = $cash->fk_modepaybank_extra;
             $amount[3] = $aryTicket['customerpay3'];
         }
         //Añadir el posible pago de puntos
         if ($aryTicket['points'] > 0) {
             dol_include_once('/rewards/class/rewards.class.php');
             $reward = new Rewards($db);
             $facture = new Facture($db);
             $facture->fetch($aryTicket['id']);
             $res = $reward->usePoints($facture, $aryTicket['points']);
         }
         $i = 1;
         $payment = new Paiement($db);
         while ($i <= $max_ite) {
             $payment->datepaye = $now;
             $payment->bank_account = $bankaccountid[$i];
             $payment->amounts[$aryTicket['id']] = $amount[$i];
             $payment->note = $langs->trans("Payment") . ' ' . $langs->trans("Facture") . ' ' . $aryTicket['ref'];
             $payment->paiementid = $modepay[$i];
             $payment->num_paiement = '';
             if ($amount[$i] != 0) {
                 $paiement_id = $payment->create($userstatic, 1);
                 if ($paiement_id > 0) {
                     if ($payment->paiementid != dol_getIdFromCode($db, 'PNT', 'c_paiement')) {
                         $result = $payment->addPaymentToBank($userstatic, 'payment', '(CustomerFacturePayment)', $bankaccountid[$i], $aryTicket['customerId'], '', '');
                         if ($result < 0) {
                             $error++;
                         }
                     }
                 } else {
                     $error++;
                 }
             }
             $i++;
         }
     }
     if ($error > 0) {
         return -1;
     } else {
         return 1;
     }
     //$paiement_id;
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:101,代码来源:pos.class.mañanero.php

示例7: 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();
     }
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:98,代码来源:rejetprelevement.class.php

示例8: 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,';
    $sql .= ' c.code as payment_code, c.libelle as payment_label,';
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:31,代码来源:loadhistory.php

示例9: values

$payment->datepaye = $now;
if ($pay == "cash") {
    $fk_bank = $rowterminal[1];
} else {
    $fk_bank = $rowterminal[3];
}
$payment->bank_account = $fk_bank;
$payment->amounts[$facture->id] = $object->total_ttc;
if ($pay == "cash") {
    $payment->paiementid = 4;
} else {
    $payment->paiementid = 6;
}
$payment->num_paiement = '';
$payment_id = $payment->create($user, 1);
$payment->addPaymentToBank($user, 'payment', 'Dolipos BAR', $fk_bank, '', '');
$facture->update_note($langs->trans("Table") . " " . str_replace("Place-", "", $object->ref), '_public');
$facture->set_paid($user);
$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 ($print == 1) {
    $sql = "SELECT value FROM " . MAIN_DB_PREFIX . "const where name='PENDING_PRINT_BAR' and entity={$entity}";
    $resql = $db->query($sql);
    $const = $db->fetch_array($resql);
    dolibarr_set_const($db, "PENDING_PRINT_BAR", $const[0] . 'F' . $row[0] . ',', 'chaine', 0, '', $entity);
}
?>
</head>
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:31,代码来源:save.php

示例10: 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;
     }
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:73,代码来源:remisecheque.class.php

示例11: _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;
}
开发者ID:ATM-Consulting,项目名称:dolibarr_module_paymentimport,代码行数:95,代码来源:paymentimport.lib.php


注:本文中的Paiement::addPaymentToBank方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。