29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
36 $langs->loadLangs(array(
'companies',
'donations'));
38 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'sclist';
40 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
41 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
42 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
45 if (empty($page) || $page == -1) {
48 $offset = $limit * $page;
49 $pageprev = $page - 1;
50 $pagenext = $page + 1;
55 $sortfield =
"d.datedon";
58 $search_status = (
GETPOST(
"search_status",
'intcomma') !=
'') ?
GETPOST(
"search_status",
'intcomma') :
"-4";
59 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
60 $search_ref =
GETPOST(
'search_ref',
'alpha');
61 $search_company =
GETPOST(
'search_company',
'alpha');
62 $search_name =
GETPOST(
'search_name',
'alpha');
63 $search_amount =
GETPOST(
'search_amount',
'alpha');
64 $optioncss =
GETPOST(
'optioncss',
'alpha');
65 $moreforfilter =
GETPOST(
'moreforfilter',
'alpha');
66 if (!$user->rights->don->lire) {
70 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
80 $hookmanager->initHooks(array(
'orderlist'));
84 $fieldstosearchall = array(
87 'd.lastname'=>
'Lastname',
88 'd.firstname'=>
'Firstname',
101 $donationstatic =
new Don($db);
104 $projectstatic =
new Project($db);
107 $help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
112 $sql =
"SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,";
113 $sql .=
" d.amount, d.fk_statut as status,";
114 $sql .=
" p.rowid as pid, p.ref, p.title, p.public";
115 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don as d LEFT JOIN ".MAIN_DB_PREFIX.
"projet AS p";
116 $sql .=
" ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity(
'donation').
")";
117 if ($search_status !=
'' && $search_status !=
'-4') {
118 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
120 if (trim($search_ref) !=
'') {
123 if (trim($search_all) !=
'') {
124 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
126 if (trim($search_company) !=
'') {
129 if (trim($search_name) !=
'') {
130 $sql .=
natural_search(array(
'd.lastname',
'd.firstname'), $search_name);
132 if ($search_amount) {
136 $sql .= $db->order($sortfield, $sortorder);
139 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
140 $result = $db->query($sql);
148 $sql .= $db->plimit($limit + 1, $offset);
150 $resql = $db->query($sql);
152 $num = $db->num_rows(
$resql);
156 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
157 $param .=
'&contextpage='.urlencode($contextpage);
159 if ($limit > 0 && $limit != $conf->liste_limit) {
160 $param .=
'&limit='.urlencode($limit);
162 if ($optioncss !=
'') {
163 $param .=
'&optioncss='.urlencode($optioncss);
165 if ($search_status && $search_status != -1) {
166 $param .=
'&search_status='.urlencode($search_status);
169 $param .=
'&search_ref='.urlencode($search_ref);
171 if ($search_company) {
172 $param .=
'&search_company='.urlencode($search_company);
175 $param .=
'&search_name='.urlencode($search_name);
177 if ($search_amount) {
178 $param .=
'&search_amount='.urlencode($search_amount);
182 if ($user->rights->don->creer) {
183 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewDonation'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/don/card.php?action=create');
186 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
187 if ($optioncss !=
'') {
188 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
190 print
'<input type="hidden" name="token" value="'.newToken().
'">';
191 print
'<input type="hidden" name="action" value="list">';
192 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
193 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
194 print
'<input type="hidden" name="page" value="'.$page.
'">';
195 print
'<input type="hidden" name="type" value="'.$type.
'">';
197 print_barre_liste($langs->trans(
"Donations"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'object_donation', 0, $newcardbutton,
'', $limit, 0, 0, 1);
200 foreach ($fieldstosearchall as $key => $val) {
201 $fieldstosearchall[$key] = $langs->trans($val);
203 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
206 print
'<div class="div-table-responsive">';
207 print
'<table class="tagtable liste'.(!empty($moreforfilter) ?
" listwithfilterbefore" :
"").
'">'.
"\n";
210 print
'<tr class="liste_titre_filter">';
211 print
'<td class="liste_titre">';
212 print
'<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.
'">';
214 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
215 print
'<td class="liste_titre">';
216 print
'<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.
'">';
219 print
'<td class="liste_titre">';
220 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
223 print
'<td class="liste_titre">';
224 print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
226 print
'<td class="liste_titre left">';
230 print
'<td class="liste_titre right">';
234 print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.
'"></td>';
235 print
'<td class="liste_titre right">';
237 Don::STATUS_DRAFT=>$langs->trans(
"DonationStatusPromiseNotValidated"),
238 Don::STATUS_VALIDATED=>$langs->trans(
"DonationStatusPromiseValidated"),
239 Don::STATUS_PAID=>$langs->trans(
"DonationStatusPaid"),
240 Don::STATUS_CANCELED=>$langs->trans(
"Canceled")
242 print
$form->selectarray(
'search_status', $liststatus, $search_status, -4, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100 onrightofpage');
244 print
'<td class="liste_titre maxwidthsearch">';
245 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
250 print
'<tr class="liste_titre">';
252 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
253 print_liste_field_titre(
"ThirdParty", $_SERVER[
"PHP_SELF"],
"d.fk_soc",
"", $param,
"", $sortfield, $sortorder);
258 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.datedon",
"", $param,
'', $sortfield, $sortorder,
'center ');
260 $langs->load(
"projects");
261 print_liste_field_titre(
"Project", $_SERVER[
"PHP_SELF"],
"d.fk_projet",
"", $param,
"", $sortfield, $sortorder);
263 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"d.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
264 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
268 while ($i < min($num, $limit)) {
269 $objp = $db->fetch_object(
$resql);
271 print
'<tr class="oddeven">';
272 $donationstatic->id = $objp->rowid;
273 $donationstatic->ref = $objp->rowid;
274 $donationstatic->lastname = $objp->lastname;
275 $donationstatic->firstname = $objp->firstname;
276 print
"<td>".$donationstatic->getNomUrl(1).
"</td>";
277 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
279 $result = $company->fetch($objp->socid);
280 if (!empty($objp->socid) && $company->id > 0) {
281 print
"<td>".$company->getNomUrl(1).
"</td>";
283 print
"<td>".$objp->societe.
"</td>";
286 print
"<td>".$objp->societe.
"</td>";
288 print
"<td>".$donationstatic->getFullName($langs).
"</td>";
289 print
'<td class="center">'.dol_print_date($db->jdate($objp->datedon),
'day').
'</td>';
293 $projectstatic->id = $objp->pid;
294 $projectstatic->ref = $objp->ref;
295 $projectstatic->id = $objp->pid;
296 $projectstatic->public = $objp->public;
297 $projectstatic->title = $objp->title;
298 print $projectstatic->getNomUrl(1);
304 print
'<td class="right"><span class="amount">'.price($objp->amount).
'</span></td>';
305 print
'<td class="right">'.$donationstatic->LibStatut($objp->status, 5).
'</td>';
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage donations.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.