60 $this->motifs = array();
61 $this->facturer = array();
63 $this->motifs[0] =
"";
64 $this->motifs[1] = $langs->trans(
"StatusMotif1");
65 $this->motifs[2] = $langs->trans(
"StatusMotif2");
66 $this->motifs[3] = $langs->trans(
"StatusMotif3");
67 $this->motifs[4] = $langs->trans(
"StatusMotif4");
68 $this->motifs[5] = $langs->trans(
"StatusMotif5");
69 $this->motifs[6] = $langs->trans(
"StatusMotif6");
70 $this->motifs[7] = $langs->trans(
"StatusMotif7");
71 $this->motifs[8] = $langs->trans(
"StatusMotif8");
73 $this->facturer[0] = $langs->trans(
"NoInvoiceRefused");
74 $this->facturer[1] = $langs->trans(
"InvoiceRefused");
88 public function create($user, $id, $motif, $date_rejet, $bonid, $facturation = 0)
94 $this->bon_id = $bonid;
98 $bankaccount = ($this->
type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
104 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"prelevement_rejet (";
105 $sql .=
"fk_prelevement_lignes";
106 $sql .=
", date_rejet";
108 $sql .=
", fk_user_creation";
109 $sql .=
", date_creation";
110 $sql .=
", afacturer";
111 $sql .=
") VALUES (";
113 $sql .=
", '".$this->db->idate($date_rejet).
"'";
115 $sql .=
", ".$user->id;
116 $sql .=
", '".$this->db->idate($now).
"'";
117 $sql .=
", ".$facturation;
120 $result = $this->
db->query($sql);
124 dol_syslog(
"RejetPrelevement::create Erreur 4");
125 dol_syslog(
"RejetPrelevement::create Erreur 4 $sql");
130 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"prelevement_lignes ";
131 $sql .=
" SET statut = 3";
132 $sql .=
" WHERE rowid = ".$id;
134 if (!$this->
db->query($sql))
136 dol_syslog(
"RejetPrelevement::create Erreur 5");
141 for ($i = 0; $i < $num; $i++) {
142 if ($this->
type ==
'bank-transfer') {
150 $fac->fetch($facs[$i][0]);
155 $pai->amounts = array();
162 $pai->amounts[$facs[$i][0]] =
price2num($facs[$i][1] * ($this->
type ==
'bank-transfer' ? 1 : -1));
163 $pai->datepaye = $date_rejet;
164 $pai->paiementid = 3;
165 $pai->num_payment = $fac->ref;
167 if ($pai->create($this->user) < 0) {
170 dol_syslog(
"RejetPrelevement::Create Error creation payment invoice ".$facs[$i][0]);
172 $result = $pai->addPaymentToBank($user,
'payment',
'(InvoiceRefused)', $bankaccount,
'',
'');
174 dol_syslog(
"RejetPrelevement::Create AddPaymentToBan Error");
179 if ($pai->validate($user) < 0) {
181 dol_syslog(
"RejetPrelevement::Create Error payment validation");
185 dol_syslog(
"RejetPrelevement::Create set_unpaid fac ".$fac->ref);
187 $fac->set_unpaid($user);
196 dol_syslog(
"RejetPrelevement::Create Commit");
199 dol_syslog(
"RejetPrelevement::Create Rollback");
200 $this->
db->rollback();
218 $sql =
"SELECT fk_user_demande";
219 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
220 $sql .=
" WHERE pfd.fk_prelevement_bons = ".$this->bon_id;
221 $sql .=
" AND pfd.fk_facture".($this->type ==
'bank-transfer' ?
'_fourn=' :
'=').$fac->id;
223 $resql = $this->db->query($sql);
229 $row = $this->
db->fetch_row(
$resql);
233 dol_syslog(
"RejetPrelevement::_send_email Erreur lecture user");
238 $emuser =
new User($this->
db);
239 $emuser->fetch($userid);
242 $soc->fetch($fac->socid);
244 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
246 $subject = $langs->transnoentities(
"InfoRejectSubject");
247 $sendto = $emuser->getFullName($langs).
" <".$emuser->email.
">";
248 $from = $this->
user->getFullName($langs).
" <".$this->
user->email.
">";
250 $trackid =
'use'.$emuser->id;
256 $socname = $soc->name;
257 $amount =
price($fac->total_ttc);
258 $userinfo = $this->
user->getFullName($langs);
260 $message = $langs->trans(
"InfoRejectMessage", $facref, $socname, $amount, $userinfo);
262 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $arr_file, $arr_mime, $arr_name,
'',
'', 0, $msgishtml, $this->
user->email,
'', $trackid);
264 $result = $mailfile->sendfile();
266 dol_syslog(
"RejetPrelevement::_send_email email envoye");
268 dol_syslog(
"RejetPrelevement::_send_email Erreur envoi email");
271 dol_syslog(
"RejetPrelevement::_send_email Userid invalide");
289 $sql =
"SELECT f.rowid as facid, pl.amount";
290 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_facture as pf";
291 if ($this->
type ==
'bank-transfer') $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture_fourn as f ON (pf.fk_facture_fourn = f.rowid)";
292 else $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture as f ON (pf.fk_facture = f.rowid)";
293 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_lignes as pl ON (pf.fk_prelevement_lignes = pl.rowid)";
294 $sql .=
" WHERE pf.fk_prelevement_lignes = ".$this->id;
295 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
307 $row = $this->
db->fetch_row(
$resql);
336 $sql =
"SELECT pr.date_rejet as dr, motif, afacturer";
337 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_rejet as pr";
338 $sql .=
" WHERE pr.fk_prelevement_lignes =".$rowid;
345 $obj = $this->
db->fetch_object(
$resql);
348 $this->date_rejet = $this->
db->jdate($obj->dr);
349 $this->motif = $this->motifs[$obj->motif];
350 $this->invoicing = $this->facturer[$obj->afacturer];
356 dol_syslog(
"RejetPrelevement::Fetch Erreur rowid=$rowid numrows=0");
360 dol_syslog(
"RejetPrelevement::Fetch Erreur rowid=$rowid");
fetch($rowid)
Retrieve withdrawal object.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
create($user, $id, $motif, $date_rejet, $bonid, $facturation=0)
Create.
Class to manage suppliers invoices.
getListInvoices($amounts=0)
Retrieve the list of invoices.
$conf db
API class for accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
Class to manage third parties objects (customers, suppliers, prospects...)
__construct($db, $user, $type)
Constructor.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
_send_email($fac)
Send email to all users that has asked the withdraw request.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile->sendfile();.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage payments of customer invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Class to manage invoices.
Class to manage payments for supplier invoices.
Class to manage standing orders rejects.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type