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_thirdparty =
GETPOST(
'search_thirdparty',
'alpha');
63 $search_name =
GETPOST(
'search_name',
'alpha');
64 $search_amount =
GETPOST(
'search_amount',
'alpha');
65 $optioncss =
GETPOST(
'optioncss',
'alpha');
66 $moreforfilter =
GETPOST(
'moreforfilter',
'alpha');
67 if (!$user->rights->don->lire) {
71 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
75 $search_thirdparty =
"";
82 $hookmanager->initHooks(array(
'orderlist'));
86 $fieldstosearchall = array(
89 'd.lastname'=>
'Lastname',
90 'd.firstname'=>
'Firstname',
103 $donationstatic =
new Don($db);
106 $projectstatic =
new Project($db);
109 $help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
114 $sql =
"SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,";
115 $sql .=
" d.amount, d.fk_statut as status,";
116 $sql .=
" p.rowid as pid, p.ref, p.title, p.public";
117 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don as d LEFT JOIN ".MAIN_DB_PREFIX.
"projet AS p";
118 $sql .=
" ON p.rowid = d.fk_projet";
119 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe AS s ON s.rowid = d.fk_soc";
120 $sql .=
" WHERE d.entity IN (".
getEntity(
'donation') .
")";
122 if ($search_status !=
'' && $search_status !=
'-4') {
123 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
125 if (trim($search_ref) !=
'') {
128 if (trim($search_all) !=
'') {
129 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
131 if (trim($search_company) !=
'') {
134 if (trim($search_thirdparty) !=
'') {
137 if (trim($search_name) !=
'') {
138 $sql .=
natural_search(array(
'd.lastname',
'd.firstname'), $search_name);
140 if ($search_amount) {
144 $sql .= $db->order($sortfield, $sortorder);
147 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
148 $result = $db->query($sql);
156 $sql .= $db->plimit($limit + 1, $offset);
158 $resql = $db->query($sql);
160 $num = $db->num_rows(
$resql);
164 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
165 $param .=
'&contextpage='.urlencode($contextpage);
167 if ($limit > 0 && $limit != $conf->liste_limit) {
168 $param .=
'&limit='.urlencode($limit);
170 if ($optioncss !=
'') {
171 $param .=
'&optioncss='.urlencode($optioncss);
173 if ($search_status && $search_status != -1) {
174 $param .=
'&search_status='.urlencode($search_status);
177 $param .=
'&search_ref='.urlencode($search_ref);
179 if ($search_company) {
180 $param .=
'&search_company='.urlencode($search_company);
183 $param .=
'&search_name='.urlencode($search_name);
185 if ($search_amount) {
186 $param .=
'&search_amount='.urlencode($search_amount);
190 if ($user->rights->don->creer) {
191 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewDonation'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/don/card.php?action=create');
194 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
195 if ($optioncss !=
'') {
196 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
198 print
'<input type="hidden" name="token" value="'.newToken().
'">';
199 print
'<input type="hidden" name="action" value="list">';
200 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
201 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
202 print
'<input type="hidden" name="page" value="'.$page.
'">';
203 print
'<input type="hidden" name="type" value="'.$type.
'">';
205 print_barre_liste($langs->trans(
"Donations"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'object_donation', 0, $newcardbutton,
'', $limit, 0, 0, 1);
208 foreach ($fieldstosearchall as $key => $val) {
209 $fieldstosearchall[$key] = $langs->trans($val);
211 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
214 print
'<div class="div-table-responsive">';
215 print
'<table class="tagtable liste'.(!empty($moreforfilter) ?
" listwithfilterbefore" :
"").
'">'.
"\n";
218 print
'<tr class="liste_titre_filter">';
219 print
'<td class="liste_titre">';
220 print
'<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.
'">';
222 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
223 print
'<td class="liste_titre">';
224 print
'<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.
'">';
227 print
'<td class="liste_titre">';
228 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
231 print
'<td class="liste_titre">';
232 print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
234 print
'<td class="liste_titre left">';
238 print
'<td class="liste_titre right">';
242 print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.
'"></td>';
243 print
'<td class="liste_titre right">';
245 Don::STATUS_DRAFT=>$langs->trans(
"DonationStatusPromiseNotValidated"),
246 Don::STATUS_VALIDATED=>$langs->trans(
"DonationStatusPromiseValidated"),
247 Don::STATUS_PAID=>$langs->trans(
"DonationStatusPaid"),
248 Don::STATUS_CANCELED=>$langs->trans(
"Canceled")
250 print
$form->selectarray(
'search_status', $liststatus, $search_status, -4, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100 onrightofpage');
252 print
'<td class="liste_titre maxwidthsearch">';
253 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
258 print
'<tr class="liste_titre">';
260 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
261 print_liste_field_titre(
"ThirdParty", $_SERVER[
"PHP_SELF"],
"d.fk_soc",
"", $param,
"", $sortfield, $sortorder);
266 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.datedon",
"", $param,
'', $sortfield, $sortorder,
'center ');
268 $langs->load(
"projects");
269 print_liste_field_titre(
"Project", $_SERVER[
"PHP_SELF"],
"d.fk_projet",
"", $param,
"", $sortfield, $sortorder);
271 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"d.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
272 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
276 while ($i < min($num, $limit)) {
277 $objp = $db->fetch_object(
$resql);
279 print
'<tr class="oddeven">';
280 $donationstatic->id = $objp->rowid;
281 $donationstatic->ref = $objp->rowid;
282 $donationstatic->lastname = $objp->lastname;
283 $donationstatic->firstname = $objp->firstname;
284 print
"<td>".$donationstatic->getNomUrl(1).
"</td>";
285 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
287 $result = $company->fetch($objp->socid);
288 if (!empty($objp->socid) && $company->id > 0) {
289 print
"<td>".$company->getNomUrl(1).
"</td>";
291 print
"<td>".$objp->societe.
"</td>";
294 print
"<td>".$objp->societe.
"</td>";
296 print
"<td>".$donationstatic->getFullName($langs).
"</td>";
297 print
'<td class="center">'.dol_print_date($db->jdate($objp->datedon),
'day').
'</td>';
301 $projectstatic->id = $objp->pid;
302 $projectstatic->ref = $objp->ref;
303 $projectstatic->id = $objp->pid;
304 $projectstatic->public = $objp->public;
305 $projectstatic->title = $objp->title;
306 print $projectstatic->getNomUrl(1);
312 print
'<td class="right"><span class="amount">'.price($objp->amount).
'</span></td>';
313 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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$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.