mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
New: Widthrawal module is no more experimental
This commit is contained in:
parent
53b95f75ff
commit
f1b30d3caa
|
|
@ -34,6 +34,7 @@ For users:
|
|||
- New: Works even if Web hosting provider has disabled glob function.
|
||||
- New: Can now send supplier order by mail.
|
||||
- New: task #10076 : Show content of message in notification module.
|
||||
- New: Widthrawal module is no more experimental.
|
||||
- Fix: Format number was wrong for ar_AR language.
|
||||
- Fix: Can change password if has only permission change password.
|
||||
- Fix: Project PDF document show the tasks.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
require("../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php');
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
|
||||
|
||||
if (!$user->rights->facture->lire)
|
||||
accessforbidden();
|
||||
|
|
@ -86,7 +87,7 @@ if ($_GET["action"] == "delete")
|
|||
* View
|
||||
*/
|
||||
|
||||
$now=gmmktime();
|
||||
$now=dol_now();
|
||||
|
||||
llxHeader('',$langs->trans("Bill"));
|
||||
|
||||
|
|
@ -98,10 +99,10 @@ $html = new Form($db);
|
|||
/* */
|
||||
/* *************************************************************************** */
|
||||
|
||||
if ($_GET["facid"] > 0)
|
||||
if ($_REQUEST["facid"] > 0 || $_REQUEST["ref"])
|
||||
{
|
||||
$fac = New Facture($db);
|
||||
if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0)
|
||||
$fac = new Facture($db);
|
||||
if ($fac->fetch($_REQUEST["facid"], $_REQUEST["ref"]) > 0)
|
||||
{
|
||||
if ($mesg) print $mesg.'<br>';
|
||||
|
||||
|
|
@ -115,22 +116,33 @@ if ($_GET["facid"] > 0)
|
|||
}
|
||||
|
||||
$head = facture_prepare_head($fac);
|
||||
dol_fiche_head($head, 'standingorders', $langs->trans('InvoiceCustomer'));
|
||||
dol_fiche_head($head, 'standingorders', $langs->trans('InvoiceCustomer'),0,'bill');
|
||||
|
||||
/*
|
||||
* Facture
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Reference du facture
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $fac->ref;
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="5">';
|
||||
$morehtmlref='';
|
||||
$discount=new DiscountAbsolute($db);
|
||||
$result=$discount->fetch(0,$fac->id);
|
||||
if ($result > 0)
|
||||
{
|
||||
$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
|
||||
}
|
||||
if ($result < 0)
|
||||
{
|
||||
dol_print_error('',$discount->error);
|
||||
}
|
||||
print $html->showrefnav($fac,'ref','',1,'facnumber','ref',$morehtmlref);
|
||||
print "</td></tr>";
|
||||
|
||||
// Societe
|
||||
print '<tr><td width="20%">'.$langs->trans("Company").'</td>';
|
||||
print '<td colspan="5">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
|
||||
print '<td colspan="5">'.$soc->getNomUrl(1,'compta');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Dates
|
||||
|
|
@ -164,8 +176,7 @@ if ($_GET["facid"] > 0)
|
|||
print '</div>';
|
||||
|
||||
/*
|
||||
* Demande de pr<EFBFBD>l<EFBFBD>vement
|
||||
*
|
||||
* Withdrawal request
|
||||
*/
|
||||
|
||||
$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
|
||||
|
|
@ -186,21 +197,29 @@ if ($_GET["facid"] > 0)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Buttons
|
||||
*/
|
||||
print "<div class=\"tabsAction\">\n";
|
||||
|
||||
// Add a withdraw request
|
||||
if ($fac->statut > 0 && $fac->paye == 0 && $fac->mode_reglement_code == 'PRE' && $num == 0)
|
||||
if ($fac->statut > 0 && $fac->paye == 0 && $num == 0)
|
||||
{
|
||||
if ($user->rights->facture->creer)
|
||||
if ($user->rights->prelevement->bons->configurer)
|
||||
{
|
||||
print '<a class="butAction" href="prelevement.php?facid='.$fac->id.'&action=new">'.$langs->trans("MakeWithdrawRequest").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#">'.$langs->trans("MakeWithdrawRequest").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print "</div><br/>";
|
||||
|
||||
|
||||
/*
|
||||
* Pr<EFBFBD>l<EFBFBD>vement
|
||||
* Withdrawals
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
|
|
@ -299,7 +318,7 @@ if ($_GET["facid"] > 0)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Facture non trouv<75>e */
|
||||
/* Invoice not found */
|
||||
print $langs->trans("ErrorBillNotFound",$_GET["facid"]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1135,8 +1135,7 @@ class BonPrelevement extends CommonObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Generation d'un bon de prelevement
|
||||
*
|
||||
* Generate a withdrawal file
|
||||
*/
|
||||
function Generate()
|
||||
{
|
||||
|
|
@ -1144,8 +1143,9 @@ class BonPrelevement extends CommonObject
|
|||
|
||||
$result = -1;
|
||||
|
||||
$this->file = fopen ($this->filename,"w");
|
||||
dol_syslog("BonPrelevement::Generate build file ".$this->filename);
|
||||
|
||||
$this->file = fopen ($this->filename,"w");
|
||||
|
||||
/*
|
||||
* En-tete Emetteur
|
||||
|
|
@ -1163,13 +1163,14 @@ class BonPrelevement extends CommonObject
|
|||
|
||||
$i = 0;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row();
|
||||
$row = $this->db->fetch_row($resql);
|
||||
|
||||
$this->EnregDestinataire($row[0],
|
||||
$row[1],
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/create.php';
|
|||
$head[$h][1] = $langs->trans("NewStandingOrder");
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("StandingOrders"));
|
||||
dol_fiche_head($head, $hselected, $langs->trans("StandingOrders"), 0, 'payment');
|
||||
|
||||
|
||||
$nb=$bprev->NbFactureAPrelever();
|
||||
|
|
@ -90,10 +90,10 @@ print '<tr><td>'.$langs->trans("NbOfInvoiceToWithdraw").'</td>';
|
|||
print '<td align="right">';
|
||||
print $nb;
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("NbOfInvoiceToWithdraw").' '.$langs->trans("ThirdPartyBankCode").'='.PRELEVEMENT_CODE_BANQUE.'</td><td align="right">';
|
||||
print '<tr><td>'.$langs->trans("NbOfInvoiceToWithdraw").' '.$langs->trans("ThirdPartyBankCode").'='.$conf->global->PRELEVEMENT_CODE_BANQUE.'</td><td align="right">';
|
||||
print $nb1;
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("NbOfInvoiceToWithdraw").' '.$langs->trans("ThirdPartyDeskCode").'='.PRELEVEMENT_CODE_GUICHET.'</td><td align="right">';
|
||||
print '<tr><td>'.$langs->trans("NbOfInvoiceToWithdraw").' '.$langs->trans("ThirdPartyDeskCode").'='.$conf->global->PRELEVEMENT_CODE_GUICHET.'</td><td align="right">';
|
||||
print $nb11;
|
||||
print '</td></tr>';
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ if ($nb)
|
|||
if ($nb) print '<a class="butAction" href="create.php?action=create">'.$langs->trans("CreateAll")."</a>\n";
|
||||
if ($nb11) print '<a class="butAction" href="create.php?action=create&banque=1">'.$langs->trans("CreateBanque")."</a>\n";
|
||||
if ($nb1) print '<a class="butAction" href="create.php?action=create&banque=1&guichet=1">'.$langs->trans("CreateGuichet")."</a>\n";
|
||||
|
||||
|
||||
print "</div>\n";
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -65,7 +65,7 @@ print '<td align="right">';
|
|||
print $bprev->NbFactureAPrelever();
|
||||
print '</td></tr>';
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("AmountToWithdraw").'</td>';
|
||||
print '<tr class="liste_total"><td>'.$langs->trans("AmountToWithdraw").'</td>';
|
||||
print '<td align="right">';
|
||||
print price($bprev->SommeAPrelever());
|
||||
print '</td></tr></table><br>';
|
||||
|
|
@ -76,8 +76,8 @@ print '</td><td valign="top" width="70%">';
|
|||
* Factures
|
||||
*/
|
||||
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.rowid as socid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s";
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
$sql.= " WHERE s.rowid = f.fk_soc";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -82,28 +82,28 @@ class modPrelevement extends DolibarrModules
|
|||
$this->rights_class = 'prelevement';
|
||||
|
||||
$this->rights[1][0] = 151;
|
||||
$this->rights[1][1] = 'Consulter les prelevements';
|
||||
$this->rights[1][1] = 'Read withdrawals';
|
||||
$this->rights[1][2] = 'r';
|
||||
$this->rights[1][3] = 1;
|
||||
$this->rights[1][4] = 'bons';
|
||||
$this->rights[1][5] = 'lire';
|
||||
|
||||
$this->rights[2][0] = 152;
|
||||
$this->rights[2][1] = 'Configurer les prelevements';
|
||||
$this->rights[2][1] = 'Create/modify a withdrawal request';
|
||||
$this->rights[2][2] = 'w';
|
||||
$this->rights[2][3] = 0;
|
||||
$this->rights[2][4] = 'bons';
|
||||
$this->rights[2][5] = 'configurer';
|
||||
|
||||
$this->rights[3][0] = 153;
|
||||
$this->rights[3][1] = 'Consulter les bons de prelevements';
|
||||
$this->rights[3][1] = 'Read a widthrawal receipt';
|
||||
$this->rights[3][2] = 'r';
|
||||
$this->rights[3][3] = 0;
|
||||
$this->rights[3][4] = 'bons';
|
||||
$this->rights[3][5] = 'lire';
|
||||
|
||||
$this->rights[4][0] = 154;
|
||||
$this->rights[4][1] = 'Creer un bon de prelevement';
|
||||
$this->rights[4][1] = 'Create/modify a withdrawal receipt';
|
||||
$this->rights[4][2] = 'w';
|
||||
$this->rights[4][3] = 0;
|
||||
$this->rights[4][4] = 'bons';
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ Permission144=Delete tasks
|
|||
Permission146=Read providers
|
||||
Permission147=Read stats
|
||||
Permission151=Read standing orders
|
||||
Permission152=Setup standing orders
|
||||
Permission152=Create/modify a standing orders request
|
||||
Permission153=Read standing orders receipts
|
||||
Permission161=Read contracts
|
||||
Permission162=Create/modify contracts
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ Permission144= Supprimer tous les projets et tâches (y compris privés dont je
|
|||
Permission146= Consulter les fournisseurs
|
||||
Permission147= Consulter les stats
|
||||
Permission151= Consulter les prélèvements
|
||||
Permission152= Configurer les prélèvements
|
||||
Permission152= Créer/modifier une demande de prélèvements
|
||||
Permission153= Consulter les bons de prélèvements
|
||||
Permission161= Consulter les contrats de services
|
||||
Permission162= Créer/modifier les contrats de services
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?PHP
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* \file scripts/prelevement/prelevement.php
|
||||
* \file scripts/withdrawals/build_withdrawal_file.php
|
||||
* \ingroup prelevement
|
||||
* \brief Script de prelevement
|
||||
* \version $Id$
|
||||
|
|
@ -30,8 +30,8 @@ $path=dirname(__FILE__).'/';
|
|||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere env dolibarr
|
||||
|
|
@ -51,12 +51,16 @@ $month = strftime("%m", $datetimeprev);
|
|||
$year = strftime("%Y", $datetimeprev);
|
||||
|
||||
$user = new user($db);
|
||||
$user->fetch(PRELEVEMENT_USER);
|
||||
$user->fetch($conf->global->PRELEVEMENT_USER);
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
if (! isset($argv[1])) { // Check parameters
|
||||
print "This script check invoices with a withdrawal request and\n";
|
||||
print "then create payment and build a withdraw file.\n";
|
||||
print "Usage: ".$script_file." simu|real\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$factures = array();
|
||||
$factures_prev = array();
|
||||
|
|
@ -80,21 +84,22 @@ if (!$error)
|
|||
$sql.= " AND f.total_ttc > 0";
|
||||
$sql.= " AND f.fk_mode_reglement = 3";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
$resql= $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row();
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
$factures[$i] = $row;
|
||||
$factures[$i] = $row;
|
||||
|
||||
$i++;
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
dol_syslog("$i factures a prelever");
|
||||
$db->free($resql);
|
||||
dol_syslog($i." invoices to withdraw.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -117,89 +122,100 @@ if (!$error)
|
|||
*
|
||||
*/
|
||||
$i = 0;
|
||||
dol_syslog("Debut verification des RIB");
|
||||
print "Start to check bank numbers RIB/IBAN.\n";
|
||||
|
||||
if (sizeof($factures) > 0)
|
||||
{
|
||||
foreach ($factures as $fac)
|
||||
{
|
||||
$fact = new Facture($db);
|
||||
$fact = new Facture($db);
|
||||
|
||||
if ($fact->fetch($fac[0]) == 1)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
if ($soc->fetch($fact->socid) == 1)
|
||||
{
|
||||
if ($soc->verif_rib() == 1)
|
||||
{
|
||||
$factures_prev[$i] = $fac;
|
||||
/* second tableau necessaire pour bon-prelevement */
|
||||
$factures_prev_id[$i] = $fac[0];
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Erreur de RIB societe $fact->socid $soc->nom");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Impossible de lire la societe");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Impossible de lire la facture");
|
||||
}
|
||||
if ($fact->fetch($fac[0]) == 1)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
if ($soc->fetch($fact->socid) == 1)
|
||||
{
|
||||
if ($soc->verif_rib() == 1)
|
||||
{
|
||||
$factures_prev[$i] = $fac;
|
||||
/* second tableau necessaire pour bon-prelevement */
|
||||
$factures_prev_id[$i] = $fac[0];
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Bad value for bank RIB/IBAN: Third party id=".$fact->socid.", name=".$soc->nom."\n";
|
||||
dol_syslog("Bad value for bank RIB/IBAN ".$fact->socid." ".$soc->nom);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Failed to read third party\n";
|
||||
dol_syslog("Failed to read third party");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
print "Failed to read invoice\n";
|
||||
dol_syslog("Failed to read invoice");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Aucune factures a traiter");
|
||||
print "No invoices to process\n";
|
||||
dol_syslog("No invoice to process");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
* Run withdrawal
|
||||
*/
|
||||
|
||||
dol_syslog(sizeof($factures_prev)." factures seront prelevees");
|
||||
print 'eeee'.$factures_prev;
|
||||
$ok=0;
|
||||
|
||||
$out=sizeof($factures_prev)." invoices will be withdrawn.";
|
||||
print $out."\n";
|
||||
dol_syslog($out);
|
||||
|
||||
if (sizeof($factures_prev) > 0)
|
||||
{
|
||||
/*
|
||||
* Ouverture de la transaction
|
||||
*
|
||||
*/
|
||||
|
||||
if (!$db->query("BEGIN"))
|
||||
if ($argv[1]==='real')
|
||||
{
|
||||
$error++;
|
||||
$ok=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Option for real mode was not set, we stop after this simulation\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
/*
|
||||
* Traitements
|
||||
*
|
||||
* We are in real mode.
|
||||
* We create withdraw receipt, payments and build withdraw into disk
|
||||
*/
|
||||
|
||||
$db->begin();
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$ref = "T".substr($year,-2).$month;
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT count(*)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons";
|
||||
$sql.= " WHERE ref LIKE '".$ref."%'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
if ($db->query($sql))
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row();
|
||||
$row = $db->fetch_row($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -213,7 +229,6 @@ if (sizeof($factures_prev) > 0)
|
|||
|
||||
/*
|
||||
* Creation du bon de prelevement
|
||||
*
|
||||
*/
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (";
|
||||
|
|
@ -223,33 +238,30 @@ if (sizeof($factures_prev) > 0)
|
|||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$ref."'";
|
||||
$sql.= ", ".$conf->entity;
|
||||
$sql.= ", ".$db->idate(mktime());
|
||||
$sql.= ", '".$db->idate(mktime())."'";
|
||||
$sql.= ")";
|
||||
|
||||
if ($db->query($sql))
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$prev_id = $db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons");
|
||||
|
||||
$bonprev = new BonPrelevement($db, $this->prelevement."/receipts/".$filebonprev);
|
||||
$bonprev = new BonPrelevement($db, $conf->prelevement->dir_output."/receipts/".$filebonprev);
|
||||
$bonprev->id = $prev_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
dol_syslog("Erreur creation du bon de prelevement");
|
||||
dol_syslog("Failed to create withdrawal ticket");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
dol_syslog("Debut generation des paiements");
|
||||
dol_syslog("Nombre de factures ".sizeof($factures_prev));
|
||||
dol_syslog("Start generation of payments");
|
||||
dol_syslog("Number of invoices: ".sizeof($factures_prev));
|
||||
|
||||
if (sizeof($factures_prev) > 0)
|
||||
{
|
||||
|
|
@ -262,14 +274,16 @@ if (sizeof($factures_prev) > 0)
|
|||
|
||||
$pai->amounts = array();
|
||||
$pai->amounts[$fac[0]] = $fact->total_ttc;
|
||||
$pai->datepaye = $db->idate($datetimeprev);
|
||||
$pai->datepaye = $datetimeprev;
|
||||
$pai->paiementid = 3; // prelevement
|
||||
$pai->num_paiement = $ref;
|
||||
|
||||
if ($pai->create($user, 1) == -1) // on appelle en no_commit
|
||||
{
|
||||
$error++;
|
||||
dol_syslog("Erreur creation paiement facture ".$fac[0]);
|
||||
$out="Failed to create payments for invoice ".$fac[0];
|
||||
print $out."\n";
|
||||
dol_syslog($out);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -304,7 +318,7 @@ if (sizeof($factures_prev) > 0)
|
|||
*/
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande";
|
||||
$sql.= " SET traite = 1";
|
||||
$sql.= ", date_traite = ".$db->idate(mktime());
|
||||
$sql.= ", date_traite = '".$db->idate(mktime())."'";
|
||||
$sql.= ", fk_prelevement_bons = ".$prev_id;
|
||||
$sql.= " WHERE rowid = ".$fac[1];
|
||||
|
||||
|
|
@ -315,27 +329,24 @@ if (sizeof($factures_prev) > 0)
|
|||
else
|
||||
{
|
||||
$error++;
|
||||
dol_syslog("Erreur mise a jour des demandes");
|
||||
dol_syslog($db->error());
|
||||
dol_syslog("Erreur mise a jour des demandes ".$db->error());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog("Fin des paiements");
|
||||
dol_syslog("End payments");
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
/*
|
||||
* Bon de Prelevement
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
dol_syslog("Debut prelevement");
|
||||
dol_syslog("Nombre de factures ".sizeof($factures_prev));
|
||||
dol_syslog("Start generation of widthdrawal");
|
||||
dol_syslog("Number of invoices ".sizeof($factures_prev));
|
||||
|
||||
if (sizeof($factures_prev) > 0)
|
||||
{
|
||||
|
|
@ -353,6 +364,7 @@ if (sizeof($factures_prev) > 0)
|
|||
|
||||
$bonprev->factures = $factures_prev_id;
|
||||
|
||||
// Build file
|
||||
$bonprev->generate();
|
||||
}
|
||||
dol_syslog( $filebonprev ) ;
|
||||
|
|
@ -382,13 +394,12 @@ if (sizeof($factures_prev) > 0)
|
|||
*/
|
||||
if (!$error)
|
||||
{
|
||||
$db->query("COMMIT");
|
||||
dol_syslog("COMMIT");
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->query("ROLLBAK");
|
||||
dol_syslog("ROLLBACK");
|
||||
$db->rollback();
|
||||
dol_syslog("Error",LOG_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,166 +0,0 @@
|
|||
<?PHP
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file scripts/prelevement/prelevement-verif.php
|
||||
* \ingroup prelevement
|
||||
* \brief Verifie que les societes qui doivent etre prelevees ont bien un RIB correct
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
$sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
$path=dirname(__FILE__).'/';
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere env dolibarr
|
||||
$version='$Revision$';
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
||||
|
||||
$error = 0;
|
||||
|
||||
$puser = new user($db);
|
||||
$puser->fetch(PRELEVEMENT_USER);
|
||||
dol_syslog("Prelevements effectues par ".$puser->fullname." [".PRELEVEMENT_USER."]");
|
||||
|
||||
dol_syslog("Raison sociale : ".PRELEVEMENT_RAISON_SOCIALE);
|
||||
dol_syslog("Numero Nation Emetteur : ".PRELEVEMENT_NUMERO_NATIONAL_EMETTEUR);
|
||||
|
||||
dol_syslog("Code etablissement : ".PRELEVEMENT_CODE_BANQUE);
|
||||
dol_syslog("Code guichet : ". PRELEVEMENT_CODE_GUICHET);
|
||||
dol_syslog("Numero compte : ".PRELEVEMENT_NUMERO_COMPTE);
|
||||
|
||||
/*
|
||||
*
|
||||
* Lectures des factures a prelever
|
||||
*
|
||||
*/
|
||||
|
||||
$factures = array();
|
||||
$factures_prev = array();
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
|
||||
$sql = "SELECT f.rowid, pfd.rowid as pfdrowid, f.fk_soc";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
|
||||
$sql .= " WHERE f.fk_statut = 1";
|
||||
$sql .= " AND f.rowid = pfd.fk_facture";
|
||||
$sql .= " AND f.paye = 0";
|
||||
$sql .= " AND pfd.traite = 0";
|
||||
$sql .= " AND f.total_ttc > 0";
|
||||
$sql .= " AND f.fk_mode_reglement = 3";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row();
|
||||
|
||||
$factures[$i] = $row;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
dol_syslog("$i factures a prelever");
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = 1;
|
||||
dol_syslog("Erreur -1");
|
||||
dol_syslog($db->error());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Verification des clients
|
||||
*
|
||||
*/
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
/*
|
||||
* Verification des RIB
|
||||
*
|
||||
*/
|
||||
$i = 0;
|
||||
dol_syslog("Debut verification des RIB");
|
||||
|
||||
if (sizeof($factures) > 0)
|
||||
{
|
||||
foreach ($factures as $fac)
|
||||
{
|
||||
$fact = new Facture($db);
|
||||
|
||||
if ($fact->fetch($fac[0]) == 1)
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
if ($soc->fetch($fact->socid) == 1)
|
||||
{
|
||||
|
||||
if ($soc->verif_rib() == 1)
|
||||
{
|
||||
|
||||
$factures_prev[$i] = $fac;
|
||||
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Erreur de RIB societe $fact->socid $soc->nom");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Impossible de lire la societe");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Impossible de lire la facture");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Aucune factures a traiter");
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog(sizeof($factures_prev)." factures sur ".sizeof($factures)." seront prelevees");
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user