31require 
'../../main.inc.php';
 
   32require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
 
   33require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
 
   34require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
 
   35require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
 
   36require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
 
   47$langs->loadLangs(array(
'banks', 
'categories', 
'withdrawals'));
 
   52  $socid = $user->socid;
 
   56$usercancreate = $user->hasRight(
'prelevement', 
'bons', 
'creer');
 
   70llxHeader(
'', $langs->trans(
"CustomersStandingOrdersArea"));
 
   73  $langs->load(
"errors");
 
   74  setEventMessages($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"PaymentByDirectDebit")), 
null, 
'errors');
 
   79  $newcardbutton .= 
dolGetButtonTitle($langs->trans(
'NewStandingOrder'), 
'', 
'fa fa-plus-circle', DOL_URL_ROOT.
'/compta/prelevement/create.php?type=');
 
   82print 
load_fiche_titre($langs->trans(
"CustomersStandingOrdersArea"), $newcardbutton);
 
   85print 
'<div class="fichecenter"><div class="fichethirdleft">';
 
   88$thirdpartystatic = 
new Societe($db);
 
   89$invoicestatic = 
new Facture($db);
 
   92print 
'<div class="div-table-responsive-no-min">';
 
   93print 
'<table class="noborder centpercent">';
 
   94print 
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
'</th></tr>';
 
   96print 
'<tr class="oddeven"><td>'.$langs->trans(
"NbOfInvoiceToWithdraw").
'</td>';
 
   97print 
'<td class="right">';
 
   98print 
'<a class="badge badge-info" href="'.DOL_URL_ROOT.
'/compta/prelevement/demandes.php?status=0">';
 
   99print $bprev->nbOfInvoiceToPay(
'direct-debit');
 
  103print 
'<tr class="oddeven"><td>'.$langs->trans(
"AmountToWithdraw").
'</td>';
 
  104print 
'<td class="right"><span class="amount">';
 
  105print 
price($bprev->SommeAPrelever(
'direct-debit'), 0, 
'', 1, -1, -1, 
'auto');
 
  106print 
'</span></td></tr></table></div><br>';
 
  113$sql = 
"SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut as status, f.paye, f.type,";
 
  114$sql .= 
" pfd.date_demande, pfd.amount,";
 
  115$sql .= 
" s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
 
  116$sql .= 
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
 
  117$sql .= 
" ".MAIN_DB_PREFIX.
"societe as s";
 
  118if (!$user->hasRight(
'societe', 
'client', 
'voir')) {
 
  119  $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
  121$sql .= 
" , ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
 
  122$sql .= 
" WHERE s.rowid = f.fk_soc";
 
  123$sql .= 
" AND f.entity IN (".getEntity(
'invoice').
")";
 
  124$sql .= 
" AND f.total_ttc > 0";
 
  126  $sql .= 
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
 
  128$sql .= 
" AND pfd.traite = 0";
 
  129$sql .= 
" AND pfd.ext_payment_id IS NULL";
 
  130$sql .= 
" AND pfd.fk_facture = f.rowid";
 
  131if (!$user->hasRight(
'societe', 
'client', 
'voir')) {
 
  132  $sql .= 
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
 
  135  $sql .= 
" AND f.fk_soc = ".((int) $socid);
 
  138$resql = $db->query($sql);
 
  140  $num = $db->num_rows($resql);
 
  143  print 
'<div class="div-table-responsive-no-min">';
 
  144  print 
'<table class="noborder centpercent">';
 
  145  print 
'<tr class="liste_titre">';
 
  146  print 
'<th colspan="5">'.$langs->trans(
"InvoiceWaitingWithdraw").
' ('.$num.
')</th></tr>';
 
  148    while ($i < $num && $i < 20) {
 
  149      $obj = $db->fetch_object($resql);
 
  151      $invoicestatic->id = $obj->rowid;
 
  152      $invoicestatic->ref = $obj->ref;
 
  153      $invoicestatic->statut = $obj->status;
 
  154      $invoicestatic->status = $obj->status;
 
  155      $invoicestatic->paye = $obj->paye;
 
  156      $invoicestatic->type = $obj->type;
 
  158      $totalallpayments = $invoicestatic->getSommePaiement(0);
 
  159      $totalallpayments += $invoicestatic->getSumCreditNotesUsed(0);
 
  160      $totalallpayments += $invoicestatic->getSumDepositsUsed(0);
 
  162      $thirdpartystatic->id = $obj->socid;
 
  163      $thirdpartystatic->name = $obj->name;
 
  164      $thirdpartystatic->email = $obj->email;
 
  165      $thirdpartystatic->tva_intra = $obj->tva_intra;
 
  166      $thirdpartystatic->siren = $obj->idprof1;
 
  167      $thirdpartystatic->siret = $obj->idprof2;
 
  168      $thirdpartystatic->ape = $obj->idprof3;
 
  169      $thirdpartystatic->idprof1 = $obj->idprof1;
 
  170      $thirdpartystatic->idprof2 = $obj->idprof2;
 
  171      $thirdpartystatic->idprof3 = $obj->idprof3;
 
  172      $thirdpartystatic->idprof4 = $obj->idprof4;
 
  173      $thirdpartystatic->idprof5 = $obj->idprof5;
 
  174      $thirdpartystatic->idprof6 = $obj->idprof6;
 
  176      print 
'<tr class="oddeven"><td class="nowraponall">';
 
  177      print $invoicestatic->getNomUrl(1, 
'withdraw');
 
  180      print 
'<td class="tdoverflowmax150">';
 
  181      print $thirdpartystatic->getNomUrl(1, 
'customer');
 
  184      print 
'<td class="right">';
 
  185      print 
'<span class="amount">'.price($obj->amount).
'</span>';
 
  188      print 
'<td class="right">';
 
  192      print 
'<td class="right">';
 
  193      print $invoicestatic->getLibStatut(3, $totalallpayments);
 
  199    $titlefortab = $langs->transnoentitiesnoconv(
"StandingOrders");
 
  200    print 
'<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"NoInvoiceToWithdraw", $titlefortab, $titlefortab).
'</span></td></tr>';
 
  202  print 
"</table></div><br>";
 
  208print 
'</div><div class="fichetwothirdright">';
 
  216$sql = 
"SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
 
  217$sql .= 
" FROM ".MAIN_DB_PREFIX.
"prelevement_bons as p";
 
  218$sql .= 
" WHERE p.type = 'debit-order'";
 
  219$sql .= 
" AND entity IN (".getEntity(
'prelevement').
")";
 
  220$sql .= 
" ORDER BY datec DESC";
 
  221$sql .= $db->plimit($limit);
 
  223$result = $db->query($sql);
 
  225  $num = $db->num_rows($result);
 
  228  print
"\n<!-- debut table -->\n";
 
  229  print 
'<div class="div-table-responsive-no-min">';
 
  230  print 
'<table class="noborder centpercent">';
 
  231  print 
'<tr class="liste_titre">';
 
  232  print 
'<th>'.$langs->trans(
"LastWithdrawalReceipt", $limit).
'</th>';
 
  233  print 
'<th>'.$langs->trans(
"Date").
'</th>';
 
  234  print 
'<th class="right">'.$langs->trans(
"Amount").
'</th>';
 
  235  print 
'<th class="right">'.$langs->trans(
"Status").
'</th>';
 
  239    while ($i < min($num, $limit)) {
 
  240      $obj = $db->fetch_object($result);
 
  242      $bprev->id = $obj->rowid;
 
  243      $bprev->ref = $obj->ref;
 
  244      $bprev->statut = $obj->statut;
 
  246      print 
'<tr class="oddeven">';
 
  248      print 
'<td class="nowraponall">';
 
  249      print $bprev->getNomUrl(1);
 
  251      print 
'<td>'.dol_print_date($db->jdate($obj->datec), 
"dayhour").
"</td>\n";
 
  252      print 
'<td class="right nowraponall"><span class="amount">'.price($obj->amount).
"</span></td>\n";
 
  253      print 
'<td class="right">'.$bprev->getLibStatut(3).
"</td>\n";
 
  259    print 
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
 
  262  print 
"</table></div><br>";
 
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
 
Class to manage withdrawal receipts.
 
Class to manage invoices.
 
Class to manage third parties objects (customers, suppliers, prospects...)
 
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
 
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
 
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
 
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.
 
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
 
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
 
prelevement_check_config($type='direct-debit')
Check need data to create standigns orders receipt file.
 
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.