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 WHERE d.entity IN (".getEntity(
'donation').
")";
139 if ($search_status !=
'' && $search_status !=
'-4') {
140 $sql .=
" AND d.fk_statut IN (".$db->sanitize($search_status).
")";
142 if (trim($search_ref) !=
'') {
145 if (trim($search_all) !=
'') {
148 if (trim($search_company) !=
'') {
151 if (trim($search_name) !=
'') {
154 if ($search_amount) {
159 $nbtotalofrecords =
'';
162 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
163 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
164 $resql = $db->query($sqlforcount);
166 $objforcount = $db->fetch_object($resql);
167 $nbtotalofrecords = $objforcount->nbtotalofrecords;
172 if (($page * $limit) > $nbtotalofrecords) {
180 $sql .= $db->order($sortfield, $sortorder);
182 $sql .= $db->plimit($limit + 1, $offset);
185 $resql = $db->query(
$sql);
191 $num = $db->num_rows($resql);
194 if ($num == 1 && !
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
195 $obj = $db->fetch_object($resql);
197 header(
"Location: ".
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$id);
222 $arrayofselected = is_array($toselect) ? $toselect : array();
226 $param .=
'&mode='.urlencode($mode);
228 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
229 $param .=
'&contextpage='.urlencode($contextpage);
231 if ($limit > 0 && $limit != $conf->liste_limit) {
232 $param .=
'&limit='.((int) $limit);
234 if ($optioncss !=
'') {
235 $param .=
'&optioncss='.urlencode($optioncss);
237 if ($search_status && $search_status != -1) {
238 $param .=
'&search_status='.urlencode($search_status);
241 $param .=
'&search_ref='.urlencode($search_ref);
243 if ($search_company) {
244 $param .=
'&search_company='.urlencode($search_company);
247 $param .=
'&search_name='.urlencode($search_name);
249 if ($search_amount) {
250 $param .=
'&search_amount='.urlencode($search_amount);
254 $arrayofmassactions = array(
260 if (!empty($permissiontodelete)) {
261 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
263 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
264 $arrayofmassactions = array();
266 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
269 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
270 if ($optioncss !=
'') {
271 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
273 print
'<input type="hidden" name="token" value="'.newToken().
'">';
274 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
275 print
'<input type="hidden" name="action" value="list">';
276 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
277 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
278 print
'<input type="hidden" name="page" value="'.$page.
'">';
279 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
280 print
'<input type="hidden" name="page_y" value="">';
281 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
282 print
'<input type="hidden" name="type" value="'.$type.
'">';
285 $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'));
286 $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'));
287 if ($user->rights->don->creer) {
288 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewDonation'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/don/card.php?action=create');
291 print_barre_liste($langs->trans(
"Donations"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'object_donation', 0, $newcardbutton,
'', $limit, 0, 0, 1);
295 foreach ($fieldstosearchall as $key => $val) {
296 $fieldstosearchall[$key] = $langs->trans($val);
297 $setupstring .= $key.
"=".$val.
";";
299 print
'<!-- Search done like if DONATION_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
300 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
303 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
304 $selectedfields = ($mode !=
'kanban' ?
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
305 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
307 print
'<div class="div-table-responsive">';
308 print
'<table class="tagtable nobottomiftotal liste'.(!empty($moreforfilter) ?
" listwithfilterbefore" :
"").
'">'.
"\n";
312 print
'<tr class="liste_titre_filter">';
315 print
'<td class="liste_titre center maxwidthsearch">';
316 $searchpicto =
$form->showFilterButtons(
'left');
320 print
'<td class="liste_titre">';
321 print
'<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.
'">';
323 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
324 print
'<td class="liste_titre">';
325 print
'<input class="flat" size="10" type="text" name="search_thirdparty" value="'.$search_thirdparty.
'">';
328 print
'<td class="liste_titre">';
329 print
'<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.
'">';
332 print
'<td class="liste_titre">';
333 print
'<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.
'">';
335 print
'<td class="liste_titre left">';
339 print
'<td class="liste_titre right">';
343 print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.
'"></td>';
344 print
'<td class="liste_titre right parentonrightofpage">';
346 Don::STATUS_DRAFT=>$langs->trans(
"DonationStatusPromiseNotValidated"),
347 Don::STATUS_VALIDATED=>$langs->trans(
"DonationStatusPromiseValidated"),
348 Don::STATUS_PAID=>$langs->trans(
"DonationStatusPaid"),
349 Don::STATUS_CANCELED=>$langs->trans(
"Canceled")
351 print
$form->selectarray(
'search_status', $liststatus, $search_status, -4, 0, 0,
'', 0, 0, 0,
'',
'search_status maxwidth100 onrightofpage');
354 print
'<td class="liste_titre center maxwidthsearch">';
355 $searchpicto =
$form->showFilterButtons();
361 $totalarray = array();
362 $totalarray[
'nbfield'] = 0;
366 print
'<tr class="liste_titre">';
370 $totalarray[
'nbfield']++;
373 $totalarray[
'nbfield']++;
374 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
375 print_liste_field_titre(
"ThirdParty", $_SERVER[
"PHP_SELF"],
"d.fk_soc",
"", $param,
"", $sortfield, $sortorder);
376 $totalarray[
'nbfield']++;
379 $totalarray[
'nbfield']++;
382 $totalarray[
'nbfield']++;
383 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"d.datedon",
"", $param,
'', $sortfield, $sortorder,
'center ');
384 $totalarray[
'nbfield']++;
386 $langs->load(
"projects");
387 print_liste_field_titre(
"Project", $_SERVER[
"PHP_SELF"],
"d.fk_projet",
"", $param,
"", $sortfield, $sortorder);
388 $totalarray[
'nbfield']++;
390 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"d.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
391 $totalarray[
'nbfield']++;
392 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"d.fk_statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
393 $totalarray[
'nbfield']++;
396 $totalarray[
'nbfield']++;
401 $savnbfield = $totalarray[
'nbfield'];
402 $totalarray = array();
403 $totalarray[
'nbfield'] = 0;
404 $imaxinloop = ($limit ? min($num, $limit) : $num);
405 while ($i < $imaxinloop) {
406 $obj = $db->fetch_object($resql);
408 $donationstatic->setVarsFromFetchObj($obj);
411 $result = $company->fetch($obj->socid);
413 if ($mode ==
'kanban') {
415 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
416 print
'<div class="box-flex-container kanban">';
419 $donationstatic->amount = $obj->amount;
420 $donationstatic->date = $obj->datedon;
421 $donationstatic->labelStatus = $obj->status;
422 $donationstatic->id = $obj->rowid;
423 $donationstatic->ref = $obj->rowid;
425 if (!empty($obj->socid) && $company->id > 0) {
426 $donationstatic->societe = $company->getNomUrl(1);
428 $donationstatic->societe = $obj->societe;
431 $object = $donationstatic;
434 if ($massactionbutton || $massaction) {
436 if (in_array($object->id, $arrayofselected)) {
440 print $donationstatic->getKanbanView(
'', array(
'selected' => $selected));
441 if ($i == ($imaxinloop - 1)) {
446 print
'<tr class="oddeven">';
450 $donationstatic->id = $obj->rowid;
451 $donationstatic->ref = $obj->rowid;
452 $donationstatic->lastname = $obj->lastname;
453 $donationstatic->firstname = $obj->firstname;
454 print
"<td>".$donationstatic->getNomUrl(1).
"</td>";
455 if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) {
456 if (!empty($obj->socid) && $company->id > 0) {
457 print
"<td>".$company->getNomUrl(1).
"</td>";
459 print
"<td>".$obj->societe.
"</td>";
462 print
"<td>".$obj->societe.
"</td>";
464 print
"<td>".$donationstatic->getFullName($langs).
"</td>";
465 print
'<td class="center">'.dol_print_date($db->jdate($obj->datedon),
'day').
'</td>';
469 $projectstatic->id = $obj->pid;
470 $projectstatic->ref = $obj->ref;
471 $projectstatic->id = $obj->pid;
472 $projectstatic->public = $obj->public;
473 $projectstatic->title = $obj->title;
474 print $projectstatic->getNomUrl(1);
480 print
'<td class="right"><span class="amount">'.price($obj->amount).
'</span></td>';
481 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.
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.