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');
52$confirm =
GETPOST(
'confirm',
'alpha');
53$cancel =
GETPOST(
'cancel',
'alpha');
54$toselect =
GETPOST(
'toselect',
'array:int');
55$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
56$backtopage =
GETPOST(
'backtopage',
'alpha');
57$optioncss =
GETPOST(
'optioncss',
'aZ');
59$groupby =
GETPOST(
'groupby',
'aZ09');
63$search_status = (
GETPOST(
"search_status",
'intcomma') !=
'') ?
GETPOST(
"search_status",
'intcomma') :
"-4";
64$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
65$search_ref =
GETPOST(
'search_ref',
'alpha');
66$search_company =
GETPOST(
'search_company',
'alpha');
67$search_thirdparty =
GETPOST(
'search_thirdparty',
'alpha');
68$search_name =
GETPOST(
'search_name',
'alpha');
69$search_amount =
GETPOST(
'search_amount',
'alpha');
70$moreforfilter =
GETPOST(
'moreforfilter',
'alpha');
74$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
75$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
77if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
81$offset = $limit * $page;
88$diroutputmassaction =
$conf->don->dir_output.
'/temp/massgeneration/'.$user->id;
89$hookmanager->initHooks(array($contextpage));
92$extrafields->fetch_name_optionals_label(
$object->table_element);
95$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
102 $sortfield =
"d.datedon";
106$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
108foreach (
$object->fields as $key => $val) {
109 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
110 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
112 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
119$fieldstosearchall = array(
122 'd.lastname' =>
'Lastname',
123 'd.firstname' =>
'Firstname',
126include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
136$permissiontoread = $user->hasRight(
'don',
'read');
137$permissiontoadd = $user->hasRight(
'don',
'write');
138$permissiontodelete = $user->hasRight(
'don',
'delete');
145if (
GETPOST(
'cancel',
'alpha')) {
149if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
153$parameters = array(
'arrayfields' => &$arrayfields);
154$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
159if (empty($reshook)) {
161 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
164 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
165 foreach (
$object->fields as $key => $val) {
167 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
168 $search[$key.
'_dtstart'] =
'';
169 $search[$key.
'_dtend'] =
'';
175 $search_company =
"";
176 $search_thirdparty =
"";
181 $search_array_options = array();
183 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
184 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
189 $objectclass =
'Don';
190 $objectlabel =
'Don';
191 $uploaddir =
$conf->don->dir_output;
194 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
206$form =
new Form($db);
210$donationstatic =
new Don($db);
211if (isModEnabled(
'project')) {
212 $projectstatic =
new Project($db);
215$title = $langs->trans(
"Donations");
216$help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
222$sql =
"SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,";
223$sql .=
" d.amount, d.fk_statut as status,";
224$sql .=
" p.rowid as pid, p.ref, p.title, p.public";
226$parameters = array();
227$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
228$sql .= $hookmanager->resPrint;
229$sql = preg_replace(
'/,\s*$/',
'', $sql);
233$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as d LEFT JOIN ".MAIN_DB_PREFIX.
"projet AS p";
234$sql .=
" ON p.rowid = d.fk_projet";
235$sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe AS s ON s.rowid = d.fk_soc";
236$sql .=
" WHERE d.entity IN (".
getEntity(
'donation') .
")";
238if ($search_status !=
'' && $search_status !=
'-4') {
239 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
241if (trim($search_ref) !=
'') {
244if (trim($search_all) !=
'') {
245 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
247if (trim($search_company) !=
'') {
250if (trim($search_thirdparty) !=
'') {
253if (trim($search_name) !=
'') {
254 $sql .=
natural_search(array(
'd.lastname',
'd.firstname'), $search_name);
261$nbtotalofrecords =
'';
264 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
265 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
266 $resql = $db->query($sqlforcount);
268 $objforcount = $db->fetch_object($resql);
269 $nbtotalofrecords = $objforcount->nbtotalofrecords;
274 if (($page * $limit) > $nbtotalofrecords) {
282$sql .= $db->order($sortfield, $sortorder);
284 $sql .= $db->plimit($limit + 1, $offset);
287$resql = $db->query($sql);
293$num = $db->num_rows($resql);
296if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
297 $obj = $db->fetch_object($resql);
299 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((
int)
$id));
307llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'mod-donation page-list bodyforlist');
324$arrayofselected = is_array($toselect) ? $toselect : array();
328 $param .=
'&mode='.urlencode($mode);
330if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
331 $param .=
'&contextpage='.urlencode($contextpage);
333if ($limit > 0 && $limit !=
$conf->liste_limit) {
334 $param .=
'&limit='.((int) $limit);
336if ($optioncss !=
'') {
337 $param .=
'&optioncss='.urlencode($optioncss);
340 $param .=
'&groupby='.urlencode($groupby);
342if ($search_status && $search_status != -1) {
343 $param .=
'&search_status='.urlencode($search_status);
346 $param .=
'&search_ref='.urlencode($search_ref);
348if ($search_company) {
349 $param .=
'&search_company='.urlencode($search_company);
352 $param .=
'&search_name='.urlencode($search_name);
355 $param .=
'&search_amount='.urlencode($search_amount);
358include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
360$parameters = array(
'param' => &$param);
361$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
362$param .= $hookmanager->resPrint;
365$arrayofmassactions = array(
371if (!empty($permissiontodelete)) {
372 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
374if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
375 $arrayofmassactions = array();
377$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
379print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
380if ($optioncss !=
'') {
381 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
383print
'<input type="hidden" name="token" value="'.newToken().
'">';
384print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
385print
'<input type="hidden" name="action" value="list">';
386print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
387print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
388print
'<input type="hidden" name="page" value="'.$page.
'">';
389print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
390print
'<input type="hidden" name="page_y" value="">';
391print
'<input type="hidden" name="mode" value="'.$mode.
'">';
392print
'<input type="hidden" name="type" value="'.$type.
'">';
395$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'));
396$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'));
398$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewDonation'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/don/card.php?action=create',
'', $permissiontoadd);
401print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_donation', 0, $newcardbutton,
'', $limit, 0, 0, 1);
404$topicmail =
"SendDonationRef";
406$objecttmp =
new Don($db);
407$trackid =
'don'.$object->id;
408include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
412 foreach ($fieldstosearchall as $key => $val) {
413 $fieldstosearchall[$key] = $langs->trans($val);
414 $setupstring .= $key.
"=".$val.
";";
416 print
'<!-- Search done like if DONATION_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
417 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
425$parameters = array();
426$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
427if (empty($reshook)) {
428 $moreforfilter .= $hookmanager->resPrint;
430 $moreforfilter = $hookmanager->resPrint;
433 'arrayfields' => &$arrayfields,
436if (!empty($moreforfilter)) {
437 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
438 print $moreforfilter;
442$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
443$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column ?
'left' :
'');
444$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
445$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
447print
'<div class="div-table-responsive">';
448print
'<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
452print
'<tr class="liste_titre_filter">';
454if (
$conf->main_checkbox_left_column) {
455 print
'<td class="liste_titre center maxwidthsearch">';
456 $searchpicto = $form->showFilterButtons(
'left');
460print
'<td class="liste_titre">';
461print
'<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.
'">';
464 print
'<td class="liste_titre">';
465 print
'<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.
'">';
468 print
'<td class="liste_titre">';
469 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
472print
'<td class="liste_titre">';
473print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
475print
'<td class="liste_titre left">';
478if (isModEnabled(
'project')) {
479 print
'<td class="liste_titre right">';
483print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.
'"></td>';
484print
'<td class="liste_titre center parentonrightofpage">';
486 Don::STATUS_DRAFT => $langs->trans(
"DonationStatusPromiseNotValidated"),
487 Don::STATUS_VALIDATED => $langs->trans(
"DonationStatusPromiseValidated"),
488 Don::STATUS_PAID => $langs->trans(
"DonationStatusPaid"),
489 Don::STATUS_CANCELED => $langs->trans(
"Canceled")
492print $form->selectarray(
'search_status', $liststatus, $search_status, -4, 0, 0,
'', 0, 0, 0,
'',
'search_status maxwidth100 onrightofpage');
495if (!
$conf->main_checkbox_left_column) {
496 print
'<td class="liste_titre center maxwidthsearch">';
497 $searchpicto = $form->showFilterButtons();
508print
'<tr class="liste_titre">';
510if (
$conf->main_checkbox_left_column) {
511 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
517 print_liste_field_titre(
"ThirdParty", $_SERVER[
"PHP_SELF"],
"d.fk_soc",
"", $param,
"", $sortfield, $sortorder);
525print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.datedon",
"", $param,
'', $sortfield, $sortorder,
'center ');
527if (isModEnabled(
'project')) {
528 $langs->load(
"projects");
529 print_liste_field_titre(
"Project", $_SERVER[
"PHP_SELF"],
"d.fk_projet",
"", $param,
"", $sortfield, $sortorder);
532print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"d.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
534print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'center ');
537if (!
$conf->main_checkbox_left_column) {
538 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
547$imaxinloop = ($limit ? min($num, $limit) : $num);
548while ($i < $imaxinloop) {
549 $obj = $db->fetch_object($resql);
554 $donationstatic->setVarsFromFetchObj($obj);
556 $donationstatic->id = $obj->rowid;
557 $donationstatic->ref = $obj->rowid;
558 $donationstatic->date = $db->jdate($obj->datedon);
559 $donationstatic->status = $obj->status;
560 $donationstatic->lastname = $obj->lastname;
561 $donationstatic->firstname = $obj->firstname;
565 $result = $company->fetch($obj->socid);
568 if ($mode ==
'kanban') {
570 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
571 print
'<div class="box-flex-container kanban">';
574 $donationstatic->amount = $obj->amount;
576 if (!empty($obj->socid) && $company->id > 0) {
577 $donationstatic->societe = $company->getNomUrl(1);
579 $donationstatic->societe = $obj->societe;
585 if ($massactionbutton || $massaction) {
587 if (in_array(
$object->id, $arrayofselected)) {
591 print $donationstatic->getKanbanView(
'', array(
'selected' => $selected));
592 if ($i == ($imaxinloop - 1)) {
599 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
602 if (
$conf->main_checkbox_left_column) {
603 print
'<td class="nowrap center">';
604 if ($massactionbutton || $massaction) {
606 if (in_array(
$object->id, $arrayofselected)) {
609 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
618 print
"<td>".$donationstatic->getNomUrl(1).
"</td>";
622 if (!empty($obj->socid) && $company->id > 0) {
623 print
"<td>".$company->getNomUrl(1).
"</td>";
625 print
"<td>".((string) $obj->societe).
"</td>";
628 print
"<td>".((string) $obj->societe).
"</td>";
632 print
"<td>".$donationstatic->getFullName($langs).
"</td>";
635 print
'<td class="center">'.dol_print_date($db->jdate($obj->datedon),
'day').
'</td>';
637 if (isModEnabled(
'project')) {
640 $projectstatic->id = $obj->pid;
641 $projectstatic->ref = $obj->ref;
642 $projectstatic->id = $obj->pid;
643 $projectstatic->public = $obj->public;
644 $projectstatic->title = $obj->title;
645 print $projectstatic->getNomUrl(1);
651 print
'<td class="right"><span class="amount">'.price($obj->amount).
'</span></td>';
654 print
'<td class="center">'.$donationstatic->LibStatut($obj->status, 5).
'</td>';
657 if (empty(
$conf->main_checkbox_left_column)) {
658 print
'<td class="nowrap center">';
659 if ($massactionbutton || $massaction) {
661 if (in_array(
$object->id, $arrayofselected)) {
664 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
679print
'</table>'.
"\n";
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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, $allowothertags=array())
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...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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.