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 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
39 $massaction =
GETPOST(
'massaction',
'alpha');
40 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'sclist';
42 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
43 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
44 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
47 $mode =
GETPOST(
'mode',
'alpha');
48 if (empty($page) || $page == -1) {
51 $offset = $limit * $page;
52 $pageprev = $page - 1;
53 $pagenext = $page + 1;
58 $sortfield =
"d.datedon";
61 $search_status = (
GETPOST(
"search_status",
'intcomma') !=
'') ?
GETPOST(
"search_status",
'intcomma') :
"-4";
62 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
63 $search_ref =
GETPOST(
'search_ref',
'alpha');
64 $search_company =
GETPOST(
'search_company',
'alpha');
65 $search_thirdparty =
GETPOST(
'search_thirdparty',
'alpha');
66 $search_name =
GETPOST(
'search_name',
'alpha');
67 $search_amount =
GETPOST(
'search_amount',
'alpha');
68 $optioncss =
GETPOST(
'optioncss',
'alpha');
69 $moreforfilter =
GETPOST(
'moreforfilter',
'alpha');
71 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
75 $search_thirdparty =
"";
82 $hookmanager->initHooks(array(
'donationlist'));
86 $fieldstosearchall = array(
89 'd.lastname'=>
'Lastname',
90 'd.firstname'=>
'Firstname',
96 $permissiontoread = $user->hasRight(
'don',
'read');
97 $permissiontoadd = $user->hasRight(
'don',
'write');
98 $permissiontodelete = $user->hasRight(
'don',
'delete');
105 if (
GETPOST(
'cancel',
'alpha')) {
109 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
120 $donationstatic =
new Don($db);
122 $projectstatic =
new Project($db);
125 $title = $langs->trans(
"Donations");
126 $help_url =
'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
131 $sql =
"SELECT d.rowid, d.datedon, d.fk_soc as socid, d.firstname, d.lastname, d.societe,";
132 $sql .=
" d.amount, d.fk_statut as status,";
133 $sql .=
" p.rowid as pid, p.ref, p.title, p.public";
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don as d LEFT JOIN ".MAIN_DB_PREFIX.
"projet AS p";
138 $sql .=
" ON p.rowid = d.fk_projet";
139 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe AS s ON s.rowid = d.fk_soc";
142 if ($search_status !=
'' && $search_status !=
'-4') {
143 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
145 if (trim($search_ref) !=
'') {
148 if (trim($search_all) !=
'') {
151 if (trim($search_company) !=
'') {
154 if (trim($search_thirdparty) !=
'') {
157 if (trim($search_name) !=
'') {
160 if ($search_amount) {
165 $nbtotalofrecords =
'';
168 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
169 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
170 $resql = $db->query($sqlforcount);
172 $objforcount = $db->fetch_object($resql);
173 $nbtotalofrecords = $objforcount->nbtotalofrecords;
178 if (($page * $limit) > $nbtotalofrecords) {
186 $sql .= $db->order($sortfield, $sortorder);
188 $sql .= $db->plimit($limit + 1, $offset);
191 $resql = $db->query(
$sql);
197 $num = $db->num_rows($resql);
200 if ($num == 1 && !
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
201 $obj = $db->fetch_object($resql);
203 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$id);
228 $arrayofselected = is_array($toselect) ? $toselect : array();
232 $param .=
'&mode='.urlencode($mode);
234 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
235 $param .=
'&contextpage='.urlencode($contextpage);
237 if ($limit > 0 && $limit != $conf->liste_limit) {
238 $param .=
'&limit='.((int) $limit);
240 if ($optioncss !=
'') {
241 $param .=
'&optioncss='.urlencode($optioncss);
243 if ($search_status && $search_status != -1) {
244 $param .=
'&search_status='.urlencode($search_status);
247 $param .=
'&search_ref='.urlencode($search_ref);
249 if ($search_company) {
250 $param .=
'&search_company='.urlencode($search_company);
253 $param .=
'&search_name='.urlencode($search_name);
255 if ($search_amount) {
256 $param .=
'&search_amount='.urlencode($search_amount);
260 $arrayofmassactions = array(
266 if (!empty($permissiontodelete)) {
267 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
269 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
270 $arrayofmassactions = array();
272 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
275 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
276 if ($optioncss !=
'') {
277 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
279 print
'<input type="hidden" name="token" value="'.newToken().
'">';
280 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
281 print
'<input type="hidden" name="action" value="list">';
282 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
283 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
284 print
'<input type="hidden" name="page" value="'.$page.
'">';
285 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
286 print
'<input type="hidden" name="page_y" value="">';
287 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
288 print
'<input type="hidden" name="type" value="'.$type.
'">';
291 $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'));
292 $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'));
293 if ($user->rights->don->creer) {
294 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewDonation'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/don/card.php?action=create');
297 print_barre_liste($langs->trans(
"Donations"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'object_donation', 0, $newcardbutton,
'', $limit, 0, 0, 1);
301 foreach ($fieldstosearchall as $key => $val) {
302 $fieldstosearchall[$key] = $langs->trans($val);
303 $setupstring .= $key.
"=".$val.
";";
305 print
'<!-- Search done like if DONATION_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
306 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
309 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
310 $selectedfields = ($mode !=
'kanban' ?
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
311 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
313 print
'<div class="div-table-responsive">';
314 print
'<table class="tagtable nobottomiftotal liste'.(!empty($moreforfilter) ?
" listwithfilterbefore" :
"").
'">'.
"\n";
318 print
'<tr class="liste_titre_filter">';
321 print
'<td class="liste_titre center maxwidthsearch">';
322 $searchpicto =
$form->showFilterButtons(
'left');
326 print
'<td class="liste_titre">';
327 print
'<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.
'">';
329 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
330 print
'<td class="liste_titre">';
331 print
'<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.
'">';
334 print
'<td class="liste_titre">';
335 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
338 print
'<td class="liste_titre">';
339 print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
341 print
'<td class="liste_titre left">';
345 print
'<td class="liste_titre right">';
349 print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.
'"></td>';
350 print
'<td class="liste_titre right parentonrightofpage">';
352 Don::STATUS_DRAFT=>$langs->trans(
"DonationStatusPromiseNotValidated"),
353 Don::STATUS_VALIDATED=>$langs->trans(
"DonationStatusPromiseValidated"),
354 Don::STATUS_PAID=>$langs->trans(
"DonationStatusPaid"),
355 Don::STATUS_CANCELED=>$langs->trans(
"Canceled")
357 print
$form->selectarray(
'search_status', $liststatus, $search_status, -4, 0, 0,
'', 0, 0, 0,
'',
'search_status maxwidth100 onrightofpage');
360 print
'<td class="liste_titre center maxwidthsearch">';
361 $searchpicto =
$form->showFilterButtons();
367 $totalarray = array();
368 $totalarray[
'nbfield'] = 0;
372 print
'<tr class="liste_titre">';
376 $totalarray[
'nbfield']++;
379 $totalarray[
'nbfield']++;
380 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
381 print_liste_field_titre(
"ThirdParty", $_SERVER[
"PHP_SELF"],
"d.fk_soc",
"", $param,
"", $sortfield, $sortorder);
382 $totalarray[
'nbfield']++;
385 $totalarray[
'nbfield']++;
388 $totalarray[
'nbfield']++;
389 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.datedon",
"", $param,
'', $sortfield, $sortorder,
'center ');
390 $totalarray[
'nbfield']++;
392 $langs->load(
"projects");
393 print_liste_field_titre(
"Project", $_SERVER[
"PHP_SELF"],
"d.fk_projet",
"", $param,
"", $sortfield, $sortorder);
394 $totalarray[
'nbfield']++;
396 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"d.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
397 $totalarray[
'nbfield']++;
398 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
399 $totalarray[
'nbfield']++;
402 $totalarray[
'nbfield']++;
407 $savnbfield = $totalarray[
'nbfield'];
408 $totalarray = array();
409 $totalarray[
'nbfield'] = 0;
410 $imaxinloop = ($limit ? min($num, $limit) : $num);
411 while ($i < $imaxinloop) {
412 $obj = $db->fetch_object($resql);
414 $donationstatic->setVarsFromFetchObj($obj);
417 $result = $company->fetch($obj->socid);
419 if ($mode ==
'kanban') {
421 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
422 print
'<div class="box-flex-container kanban">';
425 $donationstatic->amount = $obj->amount;
426 $donationstatic->date = $obj->datedon;
427 $donationstatic->labelStatus = $obj->status;
428 $donationstatic->id = $obj->rowid;
429 $donationstatic->ref = $obj->rowid;
431 if (!empty($obj->socid) && $company->id > 0) {
432 $donationstatic->societe = $company->getNomUrl(1);
434 $donationstatic->societe = $obj->societe;
437 $object = $donationstatic;
440 if ($massactionbutton || $massaction) {
442 if (in_array($object->id, $arrayofselected)) {
446 print $donationstatic->getKanbanView(
'', array(
'selected' => $selected));
447 if ($i == ($imaxinloop - 1)) {
452 print
'<tr class="oddeven">';
456 $donationstatic->id = $obj->rowid;
457 $donationstatic->ref = $obj->rowid;
458 $donationstatic->lastname = $obj->lastname;
459 $donationstatic->firstname = $obj->firstname;
460 print
"<td>".$donationstatic->getNomUrl(1).
"</td>";
461 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
462 if (!empty($obj->socid) && $company->id > 0) {
463 print
"<td>".$company->getNomUrl(1).
"</td>";
465 print
"<td>".$obj->societe.
"</td>";
468 print
"<td>".$obj->societe.
"</td>";
470 print
"<td>".$donationstatic->getFullName($langs).
"</td>";
471 print
'<td class="center">'.dol_print_date($db->jdate($obj->datedon),
'day').
'</td>';
475 $projectstatic->id = $obj->pid;
476 $projectstatic->ref = $obj->ref;
477 $projectstatic->id = $obj->pid;
478 $projectstatic->public = $obj->public;
479 $projectstatic->title = $obj->title;
480 print $projectstatic->getNomUrl(1);
486 print
'<td class="right"><span class="amount">'.price($obj->amount).
'</span></td>';
487 print
'<td class="right">'.$donationstatic->LibStatut($obj->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') && $user->hasRight('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') && $user->hasRight('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)) $sql
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...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.