31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
33if (isModEnabled(
'project')) {
34 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
46$langs->loadLangs(array(
'companies',
'donations'));
49$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
50$massaction =
GETPOST(
'massaction',
'alpha');
51$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'donationlist';
52$toselect =
GETPOST(
'toselect',
'array');
53$optioncss =
GETPOST(
'optioncss',
'alpha');
54$mode =
GETPOST(
'mode',
'alpha');
58$search_status = (
GETPOST(
"search_status",
'intcomma') !=
'') ?
GETPOST(
"search_status",
'intcomma') :
"-4";
59$search_all = trim(
GETPOST(
'search_all',
'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$moreforfilter =
GETPOST(
'moreforfilter',
'alpha');
69$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
70$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
72if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
76$offset = $limit * $page;
83$diroutputmassaction =
$conf->don->dir_output.
'/temp/massgeneration/'.$user->id;
84$hookmanager->initHooks(array($contextpage));
87$extrafields->fetch_name_optionals_label(
$object->table_element);
90$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
97 $sortfield =
"d.datedon";
101$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
103foreach (
$object->fields as $key => $val) {
104 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
105 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
107 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
114$fieldstosearchall = array(
117 'd.lastname' =>
'Lastname',
118 'd.firstname' =>
'Firstname',
121include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
131$permissiontoread = $user->hasRight(
'don',
'read');
132$permissiontoadd = $user->hasRight(
'don',
'write');
133$permissiontodelete = $user->hasRight(
'don',
'delete');
140if (
GETPOST(
'cancel',
'alpha')) {
144if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
148if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
151 $search_company =
"";
152 $search_thirdparty =
"";
163$form =
new Form($db);
167$donationstatic =
new Don($db);
168if (isModEnabled(
'project')) {
169 $projectstatic =
new Project($db);
172$title = $langs->trans(
"Donations");
173$help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
179$sql =
"SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,";
180$sql .=
" d.amount, d.fk_statut as status,";
181$sql .=
" p.rowid as pid, p.ref, p.title, p.public";
183$parameters = array();
184$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
185$sql .= $hookmanager->resPrint;
186$sql = preg_replace(
'/,\s*$/',
'', $sql);
190$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as d LEFT JOIN ".MAIN_DB_PREFIX.
"projet AS p";
191$sql .=
" ON p.rowid = d.fk_projet";
192$sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe AS s ON s.rowid = d.fk_soc";
193$sql .=
" WHERE d.entity IN (".
getEntity(
'donation') .
")";
195if ($search_status !=
'' && $search_status !=
'-4') {
196 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
198if (trim($search_ref) !=
'') {
201if (trim($search_all) !=
'') {
202 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
204if (trim($search_company) !=
'') {
207if (trim($search_thirdparty) !=
'') {
210if (trim($search_name) !=
'') {
211 $sql .=
natural_search(array(
'd.lastname',
'd.firstname'), $search_name);
218$nbtotalofrecords =
'';
221 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
222 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
223 $resql = $db->query($sqlforcount);
225 $objforcount = $db->fetch_object($resql);
226 $nbtotalofrecords = $objforcount->nbtotalofrecords;
231 if (($page * $limit) > $nbtotalofrecords) {
239$sql .= $db->order($sortfield, $sortorder);
241 $sql .= $db->plimit($limit + 1, $offset);
244$resql = $db->query($sql);
250$num = $db->num_rows($resql);
253if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
254 $obj = $db->fetch_object($resql);
256 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.
$id);
264llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'mod-donation page-list bodyforlist');
281$arrayofselected = is_array($toselect) ? $toselect : array();
285 $param .=
'&mode='.urlencode($mode);
287if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
288 $param .=
'&contextpage='.urlencode($contextpage);
290if ($limit > 0 && $limit !=
$conf->liste_limit) {
291 $param .=
'&limit='.((int) $limit);
293if ($optioncss !=
'') {
294 $param .=
'&optioncss='.urlencode($optioncss);
296if ($search_status && $search_status != -1) {
297 $param .=
'&search_status='.urlencode($search_status);
300 $param .=
'&search_ref='.urlencode($search_ref);
302if ($search_company) {
303 $param .=
'&search_company='.urlencode($search_company);
306 $param .=
'&search_name='.urlencode($search_name);
309 $param .=
'&search_amount='.urlencode($search_amount);
313$arrayofmassactions = array(
319if (!empty($permissiontodelete)) {
320 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
322if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
323 $arrayofmassactions = array();
325$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
328print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
329if ($optioncss !=
'') {
330 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
332print
'<input type="hidden" name="token" value="'.newToken().
'">';
333print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
334print
'<input type="hidden" name="action" value="list">';
335print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
336print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
337print
'<input type="hidden" name="page" value="'.$page.
'">';
338print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
339print
'<input type="hidden" name="page_y" value="">';
340print
'<input type="hidden" name="mode" value="'.$mode.
'">';
341print
'<input type="hidden" name="type" value="'.$type.
'">';
344$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'));
345$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'));
346if ($user->hasRight(
'don',
'creer')) {
348 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewDonation'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/don/card.php?action=create');
352print_barre_liste($langs->trans(
"Donations"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'object_donation', 0, $newcardbutton,
'', $limit, 0, 0, 1);
356 foreach ($fieldstosearchall as $key => $val) {
357 $fieldstosearchall[$key] = $langs->trans($val);
358 $setupstring .= $key.
"=".$val.
";";
360 print
'<!-- Search done like if DONATION_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
361 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
364$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
365$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
366$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
367$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
369print
'<div class="div-table-responsive">';
370print
'<table class="tagtable nobottomiftotal liste'.(!empty($moreforfilter) ?
" listwithfilterbefore" :
"").
'">'.
"\n";
374print
'<tr class="liste_titre_filter">';
377 print
'<td class="liste_titre center maxwidthsearch">';
378 $searchpicto = $form->showFilterButtons(
'left');
382print
'<td class="liste_titre">';
383print
'<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.
'">';
386 print
'<td class="liste_titre">';
387 print
'<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.
'">';
390 print
'<td class="liste_titre">';
391 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
394print
'<td class="liste_titre">';
395print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
397print
'<td class="liste_titre left">';
400if (isModEnabled(
'project')) {
401 print
'<td class="liste_titre right">';
405print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.
'"></td>';
406print
'<td class="liste_titre center parentonrightofpage">';
408 Don::STATUS_DRAFT => $langs->trans(
"DonationStatusPromiseNotValidated"),
409 Don::STATUS_VALIDATED => $langs->trans(
"DonationStatusPromiseValidated"),
410 Don::STATUS_PAID => $langs->trans(
"DonationStatusPaid"),
411 Don::STATUS_CANCELED => $langs->trans(
"Canceled")
414print $form->selectarray(
'search_status', $liststatus, $search_status, -4, 0, 0,
'', 0, 0, 0,
'',
'search_status maxwidth100 onrightofpage');
417 print
'<td class="liste_titre center maxwidthsearch">';
418 $searchpicto = $form->showFilterButtons();
424$totalarray = array();
425$totalarray[
'nbfield'] = 0;
429print
'<tr class="liste_titre">';
433 $totalarray[
'nbfield']++;
436$totalarray[
'nbfield']++;
438 print_liste_field_titre(
"ThirdParty", $_SERVER[
"PHP_SELF"],
"d.fk_soc",
"", $param,
"", $sortfield, $sortorder);
439 $totalarray[
'nbfield']++;
442 $totalarray[
'nbfield']++;
445$totalarray[
'nbfield']++;
446print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.datedon",
"", $param,
'', $sortfield, $sortorder,
'center ');
447$totalarray[
'nbfield']++;
448if (isModEnabled(
'project')) {
449 $langs->load(
"projects");
450 print_liste_field_titre(
"Project", $_SERVER[
"PHP_SELF"],
"d.fk_projet",
"", $param,
"", $sortfield, $sortorder);
451 $totalarray[
'nbfield']++;
453print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"d.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
454$totalarray[
'nbfield']++;
455print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
456$totalarray[
'nbfield']++;
459 $totalarray[
'nbfield']++;
464$savnbfield = $totalarray[
'nbfield'];
465$totalarray = array();
466$totalarray[
'nbfield'] = 0;
467$imaxinloop = ($limit ? min($num, $limit) : $num);
468while ($i < $imaxinloop) {
469 $obj = $db->fetch_object($resql);
471 $donationstatic->setVarsFromFetchObj($obj);
474 $result = $company->fetch($obj->socid);
476 if ($mode ==
'kanban') {
478 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
479 print
'<div class="box-flex-container kanban">';
482 $donationstatic->amount = $obj->amount;
483 $donationstatic->date = $obj->datedon;
484 $donationstatic->status = $obj->status;
485 $donationstatic->id = $obj->rowid;
486 $donationstatic->ref = $obj->rowid;
488 if (!empty($obj->socid) && $company->id > 0) {
489 $donationstatic->societe = $company->getNomUrl(1);
491 $donationstatic->societe = $obj->societe;
497 if ($massactionbutton || $massaction) {
499 if (in_array(
$object->id, $arrayofselected)) {
503 print $donationstatic->getKanbanView(
'', array(
'selected' => $selected));
504 if ($i == ($imaxinloop - 1)) {
509 $donationstatic->id = $obj->rowid;
510 $donationstatic->ref = $obj->rowid;
511 $donationstatic->lastname = $obj->lastname;
512 $donationstatic->firstname = $obj->firstname;
515 print
'<tr class="oddeven">';
521 print
"<td>".$donationstatic->getNomUrl(1).
"</td>";
525 if (!empty($obj->socid) && $company->id > 0) {
526 print
"<td>".$company->getNomUrl(1).
"</td>";
528 print
"<td>".((string) $obj->societe).
"</td>";
531 print
"<td>".((string) $obj->societe).
"</td>";
535 print
"<td>".$donationstatic->getFullName($langs).
"</td>";
538 print
'<td class="center">'.dol_print_date($db->jdate($obj->datedon),
'day').
'</td>';
540 if (isModEnabled(
'project')) {
543 $projectstatic->id = $obj->pid;
544 $projectstatic->ref = $obj->ref;
545 $projectstatic->id = $obj->pid;
546 $projectstatic->public = $obj->public;
547 $projectstatic->title = $obj->title;
548 print $projectstatic->getNomUrl(1);
554 print
'<td class="right"><span class="amount">'.price($obj->amount).
'</span></td>';
557 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...
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.