28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
30 if (!empty($conf->project->enabled)) {
31 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
35 $langs->loadLangs(array(
"companies",
"donations"));
37 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'sclist';
39 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
40 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
41 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
43 if (empty($page) || $page == -1) {
46 $offset = $limit * $page;
47 $pageprev = $page - 1;
48 $pagenext = $page + 1;
53 $sortfield =
"d.datedon";
56 $search_status = (
GETPOST(
"search_status",
'intcomma') !=
'') ?
GETPOST(
"search_status",
'intcomma') :
"-4";
57 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
58 $search_ref =
GETPOST(
'search_ref',
'alpha');
59 $search_company =
GETPOST(
'search_company',
'alpha');
60 $search_name =
GETPOST(
'search_name',
'alpha');
61 $search_amount =
GETPOST(
'search_amount',
'alpha');
62 $optioncss =
GETPOST(
'optioncss',
'alpha');
64 if (!$user->rights->don->lire) {
68 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
78 $hookmanager->initHooks(array(
'orderlist'));
82 $fieldstosearchall = array(
85 'd.lastname'=>
'Lastname',
86 'd.firstname'=>
'Firstname',
94 $donationstatic =
new Don($db);
96 if (!empty($conf->project->enabled)) {
97 $projectstatic =
new Project($db);
100 $help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
105 $sql =
"SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,";
106 $sql .=
" d.amount, d.fk_statut as status,";
107 $sql .=
" p.rowid as pid, p.ref, p.title, p.public";
108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don as d LEFT JOIN ".MAIN_DB_PREFIX.
"projet AS p";
109 $sql .=
" ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity(
'donation').
")";
110 if ($search_status !=
'' && $search_status !=
'-4') {
111 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
113 if (trim($search_ref) !=
'') {
116 if (trim($search_all) !=
'') {
117 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
119 if (trim($search_company) !=
'') {
122 if (trim($search_name) !=
'') {
123 $sql .=
natural_search(array(
'd.lastname',
'd.firstname'), $search_name);
125 if ($search_amount) {
129 $sql .= $db->order($sortfield, $sortorder);
131 $nbtotalofrecords =
'';
132 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
133 $result = $db->query($sql);
134 $nbtotalofrecords = $db->num_rows($result);
135 if (($page * $limit) > $nbtotalofrecords) {
141 $sql .= $db->plimit($limit + 1, $offset);
143 $resql = $db->query($sql);
145 $num = $db->num_rows(
$resql);
149 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
150 $param .=
'&contextpage='.urlencode($contextpage);
152 if ($limit > 0 && $limit != $conf->liste_limit) {
153 $param .=
'&limit='.urlencode($limit);
155 if ($optioncss !=
'') {
156 $param .=
'&optioncss='.urlencode($optioncss);
158 if ($search_status && $search_status != -1) {
159 $param .=
'&search_status='.urlencode($search_status);
162 $param .=
'&search_ref='.urlencode($search_ref);
164 if ($search_company) {
165 $param .=
'&search_company='.urlencode($search_company);
168 $param .=
'&search_name='.urlencode($search_name);
170 if ($search_amount) {
171 $param .=
'&search_amount='.urlencode($search_amount);
175 if ($user->rights->don->creer) {
176 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewDonation'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/don/card.php?action=create');
179 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
180 if ($optioncss !=
'') {
181 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
183 print
'<input type="hidden" name="token" value="'.newToken().
'">';
184 print
'<input type="hidden" name="action" value="list">';
185 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
186 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
187 print
'<input type="hidden" name="page" value="'.$page.
'">';
188 print
'<input type="hidden" name="type" value="'.$type.
'">';
190 print_barre_liste($langs->trans(
"Donations"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'object_donation', 0, $newcardbutton,
'', $limit, 0, 0, 1);
193 foreach ($fieldstosearchall as $key => $val) {
194 $fieldstosearchall[$key] = $langs->trans($val);
196 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
199 print
'<div class="div-table-responsive">';
200 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
203 print
'<tr class="liste_titre_filter">';
204 print
'<td class="liste_titre">';
205 print
'<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.
'">';
207 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
208 print
'<td class="liste_titre">';
209 print
'<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.
'">';
212 print
'<td class="liste_titre">';
213 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
216 print
'<td class="liste_titre">';
217 print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
219 print
'<td class="liste_titre left">';
222 if (!empty($conf->project->enabled)) {
223 print
'<td class="liste_titre right">';
227 print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.
'"></td>';
228 print
'<td class="liste_titre right">';
230 Don::STATUS_DRAFT=>$langs->trans(
"DonationStatusPromiseNotValidated"),
231 Don::STATUS_VALIDATED=>$langs->trans(
"DonationStatusPromiseValidated"),
232 Don::STATUS_PAID=>$langs->trans(
"DonationStatusPaid"),
233 Don::STATUS_CANCELED=>$langs->trans(
"Canceled")
235 print
$form->selectarray(
'search_status', $liststatus, $search_status, -4, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100');
237 print
'<td class="liste_titre maxwidthsearch">';
238 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
243 print
'<tr class="liste_titre">';
245 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
246 print_liste_field_titre(
"ThirdParty", $_SERVER[
"PHP_SELF"],
"d.fk_soc",
"", $param,
"", $sortfield, $sortorder);
251 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.datedon",
"", $param,
'', $sortfield, $sortorder,
'center ');
252 if (!empty($conf->project->enabled)) {
253 $langs->load(
"projects");
254 print_liste_field_titre(
"Project", $_SERVER[
"PHP_SELF"],
"d.fk_projet",
"", $param,
"", $sortfield, $sortorder);
256 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"d.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
257 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
261 while ($i < min($num, $limit)) {
262 $objp = $db->fetch_object(
$resql);
264 print
'<tr class="oddeven">';
265 $donationstatic->id = $objp->rowid;
266 $donationstatic->ref = $objp->rowid;
267 $donationstatic->lastname = $objp->lastname;
268 $donationstatic->firstname = $objp->firstname;
269 print
"<td>".$donationstatic->getNomUrl(1).
"</td>";
270 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
272 $result = $company->fetch($objp->socid);
273 if (!empty($objp->socid) && $company->id > 0) {
274 print
"<td>".$company->getNomUrl(1).
"</td>";
276 print
"<td>".$objp->societe.
"</td>";
279 print
"<td>".$objp->societe.
"</td>";
281 print
"<td>".$donationstatic->getFullName($langs).
"</td>";
282 print
'<td class="center">'.dol_print_date($db->jdate($objp->datedon),
'day').
'</td>';
283 if (!empty($conf->project->enabled)) {
286 $projectstatic->id = $objp->pid;
287 $projectstatic->ref = $objp->ref;
288 $projectstatic->id = $objp->pid;
289 $projectstatic->public = $objp->public;
290 $projectstatic->title = $objp->title;
291 print $projectstatic->getNomUrl(1);
297 print
'<td class="right"><span class="amount">'.price($objp->amount).
'</span></td>';
298 print
'<td class="right">'.$donationstatic->LibStatut($objp->status, 5).
'</td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage projects.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Class to manage donations.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...