diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index ecb706bf3fa..ceb20ccacc4 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -961,7 +961,7 @@ class BonPrelevement extends CommonObject $sql .= ", f.ref, sr.bic, sr.iban_prefix, sr.frstrecur"; } else { $sql .= ", CONCAT(s.firstname,' ',s.lastname) as name"; - $sql .= ", f.ref, sr.bic, sr.iban_prefix"; + $sql .= ", f.ref, sr.bic, sr.iban_prefix, 'FRST' as frstrecur"; } if ($sourcetype != 'salary') { if ($type != 'bank-transfer') { @@ -977,21 +977,30 @@ class BonPrelevement extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."salary as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_demande as pd ON f.rowid = pd.fk_salary"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as s ON s.rowid = f.fk_user"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user_rib as sr ON s.rowid = sr.fk_user"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user_rib as sr ON s.rowid = sr.fk_user"; // TODO Add AND sr.default_rib = 1 here + } + if ($sourcetype != 'salary') { + if ($type != 'bank-transfer') { + $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; + } else { + $sql .= " WHERE f.entity IN (".getEntity('supplier_invoice').')'; + } + } else { + $sql .= " WHERE f.entity IN (".getEntity('salary').')'; } - $sql .= " WHERE f.entity IN (".getEntity('invoice').')'; if ($sourcetype != 'salary') { $sql .= " AND f.fk_statut = 1"; // Invoice validated $sql .= " AND f.paye = 0"; $sql .= " AND f.total_ttc > 0"; } else { + //$sql .= " AND f.fk_statut = 1"; // Invoice validated $sql .= " AND f.paye = 0"; $sql .= " AND f.amount > 0"; } $sql .= " AND pd.traite = 0"; $sql .= " AND pd.ext_payment_id IS NULL"; if ($sourcetype != 'salary') { - $sql .= " AND sr.type = 'ban' "; + $sql .= " AND sr.type = 'ban'"; // TODO Add AND sr.type = 'ban' for users too } if ($did > 0) { $sql .= " AND pd.rowid = ".((int) $did); @@ -1003,7 +1012,7 @@ class BonPrelevement extends CommonObject $i = 0; while ($i < $num) { - $row = $this->db->fetch_row($resql); + $row = $this->db->fetch_row($resql); // TODO Replace with fetch_object() $factures[$i] = $row; // All fields if ($row[7] == 0) { diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 6d365a36dc4..aca57a79b1f 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2020 Laurent Destailleur + * Copyright (C) 2010-2023 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2010-2012 Juanjo Menent * Copyright (C) 2018 Nicolas ZABOURI @@ -31,6 +31,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -41,18 +42,18 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills')); -$type = GETPOST('type', 'aZ09'); - // Get supervariables $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list - $mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real'; + +$type = GETPOST('type', 'aZ09'); +$sourcetype = GETPOST('sourcetype', 'aZ09'); $format = GETPOST('format', 'aZ09'); $id_bankaccount = GETPOST('id_bankaccount', 'int'); $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); -$sourcetype = GETPOST('sourcetype', 'alpha'); + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { @@ -101,7 +102,6 @@ if (empty($reshook)) { } if ($action == 'create') { $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT'); - $sourcetype = GETPOST('sourcetype', 'alpha'); //var_dump($default_account);var_dump($conf->global->$default_account);var_dump($id_bankaccount);exit; if ($id_bankaccount != getDolGlobalInt($default_account)) { @@ -221,7 +221,7 @@ if ($type) { } -if (!GETPOSTISSET('sourcetype')) { +if ($sourcetype != 'salary') { $nb = $bprev->nbOfInvoiceToPay($type); $pricetowithdraw = $bprev->SommeAPrelever($type); } else { @@ -260,16 +260,13 @@ if ($mesg) { } print '
'."\n"; -if (!GETPOSTISSET('sourcetype')) { - print '
'; -} else { - print ''; -} + +print ''; +print ''; print ''; print ''; -if (GETPOSTISSET('sourcetype')) { - print ''; -} +print ''; + if ($nb) { if ($pricetowithdraw) { $title = $langs->trans('BankToReceiveWithdraw').': '; @@ -363,40 +360,52 @@ print '
'; /* * Invoices waiting for withdraw */ -if (!GETPOSTISSET('sourcetype')) { +if ($sourcetype != 'salary') { $sql = "SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,"; if ($type == 'bank-transfer') { $sql .= " f.ref_supplier,"; } - $sql .= " pfd.rowid as request_row_id, pfd.date_demande, pfd.amount"; + $sql .= " pd.rowid as request_row_id, pd.date_demande, pd.amount"; if ($type == 'bank-transfer') { $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; } else { $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; } $sql .= " ".MAIN_DB_PREFIX."societe as s,"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd"; $sql .= " WHERE s.rowid = f.fk_soc"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; } - //$sql .= " AND pfd.amount > 0"; + //$sql .= " AND pd.amount > 0"; $sql .= " AND f.total_ttc > 0"; // Avoid credit notes - $sql .= " AND pfd.traite = 0"; - $sql .= " AND pfd.ext_payment_id IS NULL"; + $sql .= " AND pd.traite = 0"; + $sql .= " AND pd.ext_payment_id IS NULL"; if ($type == 'bank-transfer') { - $sql .= " AND pfd.fk_facture_fourn = f.rowid"; + $sql .= " AND pd.fk_facture_fourn = f.rowid"; } else { - $sql .= " AND pfd.fk_facture = f.rowid"; + $sql .= " AND pd.fk_facture = f.rowid"; } if ($socid > 0) { $sql .= " AND f.fk_soc = ".((int) $socid); } } else { - $sql = "SELECT * FROM ".MAIN_DB_PREFIX."salary as s, "; - $sql .= MAIN_DB_PREFIX."prelevement_demande as pd"; - $sql .= " WHERE s.rowid = pd.fk_salary AND s.paye = 0 AND pd.traite = 0"; + $sql = "SELECT s.ref, s.rowid, s.amount, CONCAT(u.lastname, ' ', u.firstname) as name, u.rowid as uid,"; + $sql .= " pd.rowid as request_row_id, pd.date_demande, pd.amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."salary as s,"; + $sql .= " ".MAIN_DB_PREFIX."user as u,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd"; + $sql .= " WHERE s.fk_user = u.rowid"; + $sql .= " AND s.entity IN (".getEntity('salary').")"; + /*if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { + $sql .= " AND s.fk_statut = ".Facture::STATUS_VALIDATED; + }*/ + $sql .= " AND s.amount > 0"; + $sql .= " AND pd.traite = 0"; + $sql .= " AND pd.ext_payment_id IS NULL"; + $sql .= " AND s.rowid = pd.fk_salary AND s.paye = ".Salary::STATUS_UNPAID; + $sql .= " AND pd.traite = 0"; } $nbtotalofrecords = ''; @@ -522,8 +531,9 @@ if ($resql) { } else { $bac = new UserBankAccount($db); $bac->fetch(0, '', $obj->fk_user); + $salary = new Salary($db); - $salary->fetch($obj->fk_salary); + $salary->fetch($obj->rowid); } print ''; @@ -563,7 +573,7 @@ if ($resql) { print ''; } else { print ''; - $user->fetch($obj->fk_user); + $user->fetch($obj->uid); print $user->getNomUrl(-1); print ''; } diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 1c545136bdf..984bda5b6f6 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -132,14 +132,14 @@ if ($type == 'bank-transfer') { if ($sourcetype != 'salary') { $sql = "SELECT f.ref, f.rowid, f.total_ttc,"; $sql .= " s.nom as name, s.rowid as socid,"; - $sql .= " pfd.date_demande as date_demande, pfd.amount, pfd.fk_user_demande"; + $sql .= " pd.date_demande as date_demande, pd.amount, pd.fk_user_demande"; if ($type != 'bank-transfer') { $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; } else { $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; } $sql .= " ".MAIN_DB_PREFIX."societe as s,"; - $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd"; if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } @@ -152,20 +152,20 @@ if ($sourcetype != 'salary') { $sql .= " AND f.fk_soc = ".((int) $socid); } if (!$status) { - $sql .= " AND pfd.traite = 0"; + $sql .= " AND pd.traite = 0"; } - $sql .= " AND pfd.ext_payment_id IS NULL"; + $sql .= " AND pd.ext_payment_id IS NULL"; if ($status) { - $sql .= " AND pfd.traite = ".((int) $status); + $sql .= " AND pd.traite = ".((int) $status); } $sql .= " AND f.total_ttc > 0"; if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; } if ($type != 'bank-transfer') { - $sql .= " AND pfd.fk_facture = f.rowid"; + $sql .= " AND pd.fk_facture = f.rowid"; } else { - $sql .= " AND pfd.fk_facture_fourn = f.rowid"; + $sql .= " AND pd.fk_facture_fourn = f.rowid"; } if ($search_facture) { $sql .= natural_search("f.ref", $search_facture); @@ -177,17 +177,30 @@ if ($sourcetype != 'salary') { } else { $sql = "SELECT s.rowid,s.amount as total_ttc, pd.amount,"; $sql .= " s.fk_user, pd.date_demande, pd.fk_salary, CONCAT(u.firstname,' ',u.lastname) as nom"; - $sql .= " FROM ".MAIN_DB_PREFIX."salary as s, ".MAIN_DB_PREFIX."user as u, "; - $sql .= MAIN_DB_PREFIX."prelevement_demande as pd"; + $sql .= " FROM ".MAIN_DB_PREFIX."salary as s, ".MAIN_DB_PREFIX."user as u,"; + $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pd"; $sql .= " WHERE s.rowid = pd.fk_salary"; $sql .= " AND u.rowid = s.fk_user"; - $sql .=" AND s.paye = 0 AND pd.traite = 0"; + $sql .= " AND s.entity IN (".getEntity("salary").")"; + /*if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { + $sql .= " AND s.statut = ".Salary::STATUS_UNPAID; + }*/ + if (!$status) { + $sql .= " AND pd.traite = 0"; + } + $sql .= " AND pd.ext_payment_id IS NULL"; + if ($status) { + $sql .= " AND pd.traite = ".((int) $status); + } + $sql .= " AND s.amount > 0"; + $sql .= " AND s.paye = ".Salary::STATUS_UNPAID; if ($search_facture) { $sql .= natural_search("s.rowid", $search_facture); } if ($search_societe) { $sql .= natural_search("CONCAT(u.firstname,' ',u.lastname)", $search_societe); } + //print $sql; } // Count total nb of records $nbtotalofrecords = ''; @@ -248,26 +261,41 @@ $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circl print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; -print_liste_field_titre(($sourcetype ? "RefSalary" : "Bill"), $_SERVER["PHP_SELF"]); -print_liste_field_titre(($sourcetype ? "Employee" :"Company"), $_SERVER["PHP_SELF"]); -print_liste_field_titre("AmountRequested", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'right '); -print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); -print_liste_field_titre(''); -print ''; - -print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} print ''; print ''; print ''; print ''; // Action column -print ''; +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} +print ''; + +print ''; +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre(''); +} +print_liste_field_titre(($sourcetype ? "RefSalary" : "Bill"), $_SERVER["PHP_SELF"]); +print_liste_field_titre(($sourcetype ? "Employee" :"Company"), $_SERVER["PHP_SELF"]); +print_liste_field_titre("AmountRequested", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'right '); +print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre(''); +} print ''; $userstatic = new User($db); @@ -287,6 +315,11 @@ while ($i < min($num, $limit)) { } print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + // Ref facture print ''; - print ''; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print ''; $i++; } -print "
'; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; if ($sourcetype != 'salary') { @@ -314,13 +347,18 @@ while ($i < min($num, $limit)) { print ''.dol_print_date($db->jdate($obj->date_demande), 'day').'

"; +print ""; +print "
"; +print "
"; print '
'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 658e4cfef89..5df052b6a32 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -13,8 +13,8 @@ * Copyright (C) 2015 Ari Elbaz (elarifr) * Copyright (C) 2015-2018 Charlene Benke * Copyright (C) 2016 Raphaël Doursenaud - * Copyright (C) 2018-2023 Frédéric France - * Copyright (C) 2018 David Beniamine + * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018 David Beniamine * * 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