Newer
Older
*
*/
if (!$error)
{
$this->db->query("COMMIT");
dolibarr_syslog("COMMIT");
}
else
{
$this->db->query("ROLLBAK");
dolibarr_syslog("ROLLBACK");
}
}
}
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
/*
*
*
*/
function DeleteNotificationById($rowid)
{
$result = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_notifications ";
$sql .= " WHERE rowid = '".$rowid."';";
if ($this->db->query($sql))
{
return 0;
}
else
{
return -1;
}
}
/*
*
*/
function DeleteNotification($user, $action)
{
$result = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_notifications ";
$sql .= " WHERE fk_user = '".$user."' AND action = '".$action."';";
if ($this->db->query($sql))
{
return 0;
}
else
{
return -1;
}
}
/*
*
*
*/
function AddNotification($user, $action)
{
$result = 0;
if ($this->DeleteNotification($user, $action) == 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_notifications ";
$sql .= " (fk_user, action )";
$sql .= " VALUES ('".$user."','".$action."');";
if ($this->db->query($sql))
{
$result = 0;
}
else
{
$result = -1;
dolibarr_syslog("BonPrelevement::AddNotification Erreur $result");
}
}
return $result;
}
/**
* Gnration d'un bon de prlvement
$result = -1;
/*
* En-tete Emetteur
*/
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
$sql = "SELECT rowid, client_nom, code_banque, code_guichet, number, amount";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes";
$sql .= " WHERE fk_prelevement_bons = ".$this->id;
$i = 0;
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
while ($i < $num)
{
$row = $this->db->fetch_row();
$this->EnregDestinataire($row[0],
$row[1],
$row[2],
$row[3],
$row[4],
$row[5]);
$this->total = $this->total + $row[5];
$i++;
}
}
else
{
$result = -2;
}
/*
$nbfactures = sizeof($this->factures);
for ($i = 0 ; $i < $nbfactures ; $i++)
{
$fac = new Facture($this->db);
$fac->fetch($this->factures[$i]);
$fac->fetch_client();
$fac->client->rib();
if ($fac->client->bank_account->verif()) {
$this->total = $this->total + $fac->total_ttc;
print $fac->client->bank_account->error_message;
*/
/*
* Pied de page total
*/
$this->EnregTotal($this->total);
function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount)
fputs ($this->file, "08"); // Prlvement ordinaire
fputs ($this->file, " "); // Zone Rserve B2
fputs ($this->file, $this->numero_national_emetteur); // Numro National d'emmetteur B3
// Date d'chance C1
fputs ($this->file, " ");
fputs ($this->file, strftime("%d%m", $this->date_echeance));
fputs ($this->file, substr(strftime("%y", $this->date_echeance),1));
fputs ($this->file, substr($client->nom. " ",0,24));
fputs ($this->file, substr(" ",0,24));
fputs ($this->file, substr("000000000000000".$rib_number, -11));
fputs ($this->file, substr("000000000000000".$montant, -16));
// Libell F
fputs ($this->file, substr("*".$this->ref.$rowid." ",0,13));
fputs ($this->file, substr(" ",0,18));
fputs ($this->file, substr(" ",0,5));
fputs ($this->file, "\n");
}
/*
* Enregistrements destinataires
*
*
*/
function EnregDestinataireVersion1($fac)
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
{
fputs ($this->file, "06");
fputs ($this->file, "08"); // Prlvement ordinaire
fputs ($this->file, " "); // Zone Rserve B2
fputs ($this->file, $this->numero_national_emetteur); // Numro National d'emmetteur B3
// Date d'chance C1
fputs ($this->file, " ");
fputs ($this->file, strftime("%d%m", $this->date_echeance));
fputs ($this->file, substr(strftime("%y", $this->date_echeance),1));
// Raison Sociale Destinataire C2
fputs ($this->file, substr($fac->client->nom. " ",0,24));
// Reference de la remise crancier D1
fputs ($this->file, substr(" ",0,24));
// Zone Rserve D2
fputs ($this->file, substr(" ",0,8));
// Code Guichet D3
fputs ($this->file, $fac->client->bank_account->code_guichet);
// Numero de compte D4
fputs ($this->file, substr("000000000000000".$fac->client->bank_account->number, -11));
// Zone E Montant
$montant = (round($fac->total_ttc,2) * 100);
fputs ($this->file, substr("000000000000000".$montant, -16));
// Libell F
fputs ($this->file, substr("*".$fac->ref." ",0,13));
fputs ($this->file, substr(" ",0,18));
// Code tablissement G1
fputs ($this->file, $fac->client->bank_account->code_banque);
// Zone Rserve G2
fputs ($this->file, substr(" ",0,5));
fputs ($this->file, "\n");
}
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
/*
*
*
*/
function EnregEmetteur()
{
fputs ($this->file, "03");
fputs ($this->file, "08"); // Prlvement ordinaire
fputs ($this->file, " "); // Zone Rserve B2
fputs ($this->file, $this->numero_national_emetteur); // Numro National d'emmetteur B3
// Date d'chance C1
fputs ($this->file, " ");
fputs ($this->file, strftime("%d%m", $this->date_echeance));
fputs ($this->file, substr(strftime("%y", $this->date_echeance),1));
// Raison Sociale C2
fputs ($this->file, substr($this->raison_sociale. " ",0,24));
// Reference de la remise crancier D1 sur 7 caractres
fputs ($this->file, substr($this->reference_remise. " ",0,7));
// Zone Rserve D1-2
fputs ($this->file, substr(" ",0,17));
// Zone Rserve D2
fputs ($this->file, substr(" ",0,2));
fputs ($this->file, "E");
fputs ($this->file, substr(" ",0,5));
// Code Guichet D3
fputs ($this->file, $this->emetteur_code_guichet);
// Numero de compte D4
fputs ($this->file, substr("000000000000000".$this->emetteur_numero_compte, -11));
// Zone Rserve E
fputs ($this->file, substr(" ",0,16));
// Zone Rserve F
fputs ($this->file, substr(" ",0,31));
// Code tablissement
fputs ($this->file, $this->emetteur_code_etablissement);
// Zone Rserve G
fputs ($this->file, substr(" ",0,5));
fputs ($this->file, "\n");
}
/*
* Pied de page
*
*/
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
function EnregTotal($total)
{
fputs ($this->file, "08");
fputs ($this->file, "08"); // Prlvement ordinaire
fputs ($this->file, " "); // Zone Rserve B2
fputs ($this->file, $this->numero_national_emetteur); // Numro National d'emmetteur B3
// Rserv C1
fputs ($this->file, substr(" ",0,12));
// Raison Sociale C2
fputs ($this->file, substr(" ",0,24));
// D1
fputs ($this->file, substr(" ",0,24));
// Zone Rserve D2
fputs ($this->file, substr(" ",0,8));
// Code Guichet D3
fputs ($this->file, substr(" ",0,5));
// Numero de compte D4
fputs ($this->file, substr(" ",0,11));
// Zone E Montant
$montant = ($total * 100);
fputs ($this->file, substr("000000000000000".$montant, -16));
// Zone Rserve F
fputs ($this->file, substr(" ",0,31));
// Code tablissement
fputs ($this->file, substr(" ",0,5));
// Zone Rserve F
fputs ($this->file, substr(" ",0,5));
fputs ($this->file, "\n");
}
}
?>