30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
32if (isModEnabled(
'project')) {
33 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
37$langs->loadLangs(array(
'companies',
'donations'));
40$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
41$massaction =
GETPOST(
'massaction',
'alpha');
42$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'donationlist';
43$toselect =
GETPOST(
'toselect',
'array');
44$optioncss =
GETPOST(
'optioncss',
'alpha');
45$mode =
GETPOST(
'mode',
'alpha');
49$search_status = (
GETPOST(
"search_status",
'intcomma') !=
'') ?
GETPOST(
"search_status",
'intcomma') :
"-4";
50$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
51$search_ref =
GETPOST(
'search_ref',
'alpha');
52$search_company =
GETPOST(
'search_company',
'alpha');
53$search_thirdparty =
GETPOST(
'search_thirdparty',
'alpha');
54$search_name =
GETPOST(
'search_name',
'alpha');
55$search_amount =
GETPOST(
'search_amount',
'alpha');
56$moreforfilter =
GETPOST(
'moreforfilter',
'alpha');
60$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
61$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
63if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
67$offset = $limit * $page;
74$diroutputmassaction = $conf->don->dir_output.
'/temp/massgeneration/'.$user->id;
75$hookmanager->initHooks(array($contextpage));
78$extrafields->fetch_name_optionals_label(
$object->table_element);
81$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
88 $sortfield =
"d.datedon";
92$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
94foreach (
$object->fields as $key => $val) {
95 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
96 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
98 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
105$fieldstosearchall = array(
108 'd.lastname' =>
'Lastname',
109 'd.firstname' =>
'Firstname',
112include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
122$permissiontoread = $user->hasRight(
'don',
'read');
123$permissiontoadd = $user->hasRight(
'don',
'write');
124$permissiontodelete = $user->hasRight(
'don',
'delete');
131if (
GETPOST(
'cancel',
'alpha')) {
135if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
139if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
142 $search_company =
"";
143 $search_thirdparty =
"";
154$form =
new Form($db);
158$donationstatic =
new Don($db);
159if (isModEnabled(
'project')) {
160 $projectstatic =
new Project($db);
163$title = $langs->trans(
"Donations");
164$help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
170$sql =
"SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,";
171$sql .=
" d.amount, d.fk_statut as status,";
172$sql .=
" p.rowid as pid, p.ref, p.title, p.public";
174$parameters = array();
175$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
176$sql .= $hookmanager->resPrint;
177$sql = preg_replace(
'/,\s*$/',
'', $sql);
181$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as d LEFT JOIN ".MAIN_DB_PREFIX.
"projet AS p";
182$sql .=
" ON p.rowid = d.fk_projet";
183$sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe AS s ON s.rowid = d.fk_soc";
184$sql .=
" WHERE d.entity IN (".
getEntity(
'donation') .
")";
186if ($search_status !=
'' && $search_status !=
'-4') {
187 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
189if (trim($search_ref) !=
'') {
192if (trim($search_all) !=
'') {
193 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
195if (trim($search_company) !=
'') {
198if (trim($search_thirdparty) !=
'') {
201if (trim($search_name) !=
'') {
202 $sql .=
natural_search(array(
'd.lastname',
'd.firstname'), $search_name);
209$nbtotalofrecords =
'';
212 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
213 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
214 $resql = $db->query($sqlforcount);
216 $objforcount = $db->fetch_object($resql);
217 $nbtotalofrecords = $objforcount->nbtotalofrecords;
222 if (($page * $limit) > $nbtotalofrecords) {
230$sql .= $db->order($sortfield, $sortorder);
232 $sql .= $db->plimit($limit + 1, $offset);
235$resql = $db->query($sql);
241$num = $db->num_rows($resql);
244if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
245 $obj = $db->fetch_object($resql);
247 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.
$id);
255llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'mod-donation page-list bodyforlist');
272$arrayofselected = is_array($toselect) ? $toselect : array();
276 $param .=
'&mode='.urlencode($mode);
278if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
279 $param .=
'&contextpage='.urlencode($contextpage);
281if ($limit > 0 && $limit != $conf->liste_limit) {
282 $param .=
'&limit='.((int) $limit);
284if ($optioncss !=
'') {
285 $param .=
'&optioncss='.urlencode($optioncss);
287if ($search_status && $search_status != -1) {
288 $param .=
'&search_status='.urlencode($search_status);
291 $param .=
'&search_ref='.urlencode($search_ref);
293if ($search_company) {
294 $param .=
'&search_company='.urlencode($search_company);
297 $param .=
'&search_name='.urlencode($search_name);
300 $param .=
'&search_amount='.urlencode($search_amount);
304$arrayofmassactions = array(
310if (!empty($permissiontodelete)) {
311 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
313if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
314 $arrayofmassactions = array();
316$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
319print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
320if ($optioncss !=
'') {
321 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
323print
'<input type="hidden" name="token" value="'.newToken().
'">';
324print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
325print
'<input type="hidden" name="action" value="list">';
326print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
327print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
328print
'<input type="hidden" name="page" value="'.$page.
'">';
329print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
330print
'<input type="hidden" name="page_y" value="">';
331print
'<input type="hidden" name="mode" value="'.$mode.
'">';
332print
'<input type="hidden" name="type" value="'.$type.
'">';
335$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss' =>
'reposition'));
336$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
337if ($user->hasRight(
'don',
'creer')) {
339 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewDonation'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/don/card.php?action=create');
343print_barre_liste($langs->trans(
"Donations"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'object_donation', 0, $newcardbutton,
'', $limit, 0, 0, 1);
347 foreach ($fieldstosearchall as $key => $val) {
348 $fieldstosearchall[$key] = $langs->trans($val);
349 $setupstring .= $key.
"=".$val.
";";
351 print
'<!-- Search done like if DONATION_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
352 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
355$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
356$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
357$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
358$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
360print
'<div class="div-table-responsive">';
361print
'<table class="tagtable nobottomiftotal liste'.(!empty($moreforfilter) ?
" listwithfilterbefore" :
"").
'">'.
"\n";
365print
'<tr class="liste_titre_filter">';
368 print
'<td class="liste_titre center maxwidthsearch">';
369 $searchpicto = $form->showFilterButtons(
'left');
373print
'<td class="liste_titre">';
374print
'<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.
'">';
377 print
'<td class="liste_titre">';
378 print
'<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.
'">';
381 print
'<td class="liste_titre">';
382 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
385print
'<td class="liste_titre">';
386print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
388print
'<td class="liste_titre left">';
391if (isModEnabled(
'project')) {
392 print
'<td class="liste_titre right">';
396print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.
'"></td>';
397print
'<td class="liste_titre center parentonrightofpage">';
399 Don::STATUS_DRAFT => $langs->trans(
"DonationStatusPromiseNotValidated"),
400 Don::STATUS_VALIDATED => $langs->trans(
"DonationStatusPromiseValidated"),
401 Don::STATUS_PAID => $langs->trans(
"DonationStatusPaid"),
402 Don::STATUS_CANCELED => $langs->trans(
"Canceled")
405print $form->selectarray(
'search_status', $liststatus, $search_status, -4, 0, 0,
'', 0, 0, 0,
'',
'search_status maxwidth100 onrightofpage');
408 print
'<td class="liste_titre center maxwidthsearch">';
409 $searchpicto = $form->showFilterButtons();
415$totalarray = array();
416$totalarray[
'nbfield'] = 0;
420print
'<tr class="liste_titre">';
424 $totalarray[
'nbfield']++;
427$totalarray[
'nbfield']++;
429 print_liste_field_titre(
"ThirdParty", $_SERVER[
"PHP_SELF"],
"d.fk_soc",
"", $param,
"", $sortfield, $sortorder);
430 $totalarray[
'nbfield']++;
433 $totalarray[
'nbfield']++;
436$totalarray[
'nbfield']++;
437print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.datedon",
"", $param,
'', $sortfield, $sortorder,
'center ');
438$totalarray[
'nbfield']++;
439if (isModEnabled(
'project')) {
440 $langs->load(
"projects");
441 print_liste_field_titre(
"Project", $_SERVER[
"PHP_SELF"],
"d.fk_projet",
"", $param,
"", $sortfield, $sortorder);
442 $totalarray[
'nbfield']++;
444print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"d.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
445$totalarray[
'nbfield']++;
446print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
447$totalarray[
'nbfield']++;
450 $totalarray[
'nbfield']++;
455$savnbfield = $totalarray[
'nbfield'];
456$totalarray = array();
457$totalarray[
'nbfield'] = 0;
458$imaxinloop = ($limit ? min($num, $limit) : $num);
459while ($i < $imaxinloop) {
460 $obj = $db->fetch_object($resql);
462 $donationstatic->setVarsFromFetchObj($obj);
465 $result = $company->fetch($obj->socid);
467 if ($mode ==
'kanban') {
469 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
470 print
'<div class="box-flex-container kanban">';
473 $donationstatic->amount = $obj->amount;
474 $donationstatic->date = $obj->datedon;
475 $donationstatic->status = $obj->status;
476 $donationstatic->id = $obj->rowid;
477 $donationstatic->ref = $obj->rowid;
479 if (!empty($obj->socid) && $company->id > 0) {
480 $donationstatic->societe = $company->getNomUrl(1);
482 $donationstatic->societe = $obj->societe;
488 if ($massactionbutton || $massaction) {
490 if (in_array(
$object->id, $arrayofselected)) {
494 print $donationstatic->getKanbanView(
'', array(
'selected' => $selected));
495 if ($i == ($imaxinloop - 1)) {
500 print
'<tr class="oddeven">';
504 $donationstatic->id = $obj->rowid;
505 $donationstatic->ref = $obj->rowid;
506 $donationstatic->lastname = $obj->lastname;
507 $donationstatic->firstname = $obj->firstname;
508 print
"<td>".$donationstatic->getNomUrl(1).
"</td>";
510 if (!empty($obj->socid) && $company->id > 0) {
511 print
"<td>".$company->getNomUrl(1).
"</td>";
513 print
"<td>".((string) $obj->societe).
"</td>";
516 print
"<td>".((string) $obj->societe).
"</td>";
518 print
"<td>".$donationstatic->getFullName($langs).
"</td>";
519 print
'<td class="center">'.dol_print_date($db->jdate($obj->datedon),
'day').
'</td>';
520 if (isModEnabled(
'project')) {
523 $projectstatic->id = $obj->pid;
524 $projectstatic->ref = $obj->ref;
525 $projectstatic->id = $obj->pid;
526 $projectstatic->public = $obj->public;
527 $projectstatic->title = $obj->title;
528 print $projectstatic->getNomUrl(1);
534 print
'<td class="right"><span class="amount">'.price($obj->amount).
'</span></td>';
537 print
'<td class="center">'.$donationstatic->LibStatut($obj->status, 5).
'</td>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 donations.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
print_barre_liste($title, $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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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.