diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index c951f36db6e..7ef9b36487c 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -1,6 +1,7 @@ - * Copyright (C) 2018 Frédéric France +/* Copyright (C) 2001-2002 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2016 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,405 +18,612 @@ */ /** - * \file htdocs/adherents/subscription/card.php - * \ingroup member - * \brief Page to add/edit/remove a member subscription + * \file htdocs/adherents/subscription/list.php + * \ingroup member + * \brief list of subscription */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -if (! empty($conf->banque->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -} +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -// Load translation files required by the page -$langs->loadLangs(array("companies","members","bills","users")); +$langs->loadLangs(array("members","companies")); + +$action=GETPOST('action','aZ09'); +$massaction=GETPOST('massaction','alpha'); +$confirm=GETPOST('confirm','alpha'); +$toselect = GETPOST('toselect', 'array'); + +$filter=GETPOST("filter","alpha"); +$statut=(GETPOSTISSET("statut")?GETPOST("statut","alpha"):1); +$search_ref=GETPOST('search_ref','alpha'); +$search_type=GETPOST('search_type','alpha'); +$search_lastname=GETPOST('search_lastname','alpha'); +$search_firstname=GETPOST('search_firstname','alpha'); +$search_login=GETPOST('search_login','alpha'); +$search_note=GETPOST('search_note','alpha'); +$search_account=GETPOST('search_account','int'); +$search_amount=GETPOST('search_amount','alpha'); +$optioncss = GETPOST('optioncss','alpha'); + +$date_select=GETPOST("date_select",'alpha'); + +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) { $sortorder="DESC"; } +if (! $sortfield) { $sortfield="c.dateadh"; } -$adh = new Adherent($db); $object = new Subscription($db); -$errmsg=''; -$action=GETPOST("action",'alpha'); -$rowid=GETPOST("rowid","int")?GETPOST("rowid","int"):GETPOST("id","int"); -$typeid=GETPOST("typeid","int"); -$cancel=GETPOST('cancel','alpha'); -$confirm=GETPOST('confirm'); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('subscriptionlist')); +$extrafields = new ExtraFields($db); -if (! $user->rights->adherent->cotisation->lire) - accessforbidden(); +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('subscription'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); -$permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( +); +$arrayfields=array( + 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'd.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), + 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), + 'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), + 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), + 't.libelle'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'd.bank'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1, 'enabled'=>(! empty($conf->banque->enabled))), + /*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0), + 'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/ + 'd.datedebut'=>array('label'=>$langs->trans("DateSubscription"), 'checked'=>1, 'position'=>100), + 'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>101), + 'd.amount'=>array('label'=>$langs->trans("Amount"), 'checked'=>1, 'position'=>102), + 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), +// 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) +); + +// Security check +$result=restrictedArea($user,'adherent','','','cotisation'); /* - * Actions + * Actions */ -if ($cancel) $action=''; +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } -//include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once +$parameters=array('socid'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - -//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once - - -if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $cancel) +if (empty($reshook)) { - // Charge objet actuel - $result=$object->fetch($rowid); - if ($result > 0) - { - $db->begin(); + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - $errmsg=''; - - if ($object->fk_bank) - { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - - // If transaction consolidated - if ($accountline->rappro) - { - $errmsg=$langs->trans("SubscriptionLinkedToConciliatedTransaction"); - } - else - { - $accountline->datev=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $accountline->dateo=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $accountline->amount=$_POST["amount"]; - $result=$accountline->update($user); - if ($result < 0) - { - $errmsg=$accountline->error; - } - } - } - - if (! $errmsg) - { - // Modifie valeures - $object->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $object->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']); - $object->note=$_POST["note"]; - $object->amount=$_POST["amount"]; - //print 'datef='.$object->datef.' '.$_POST['datesubendday']; - - $result=$object->update($user); - if ($result >= 0 && ! count($object->errors)) - { - $db->commit(); - - header("Location: card.php?rowid=".$object->id); - exit; - } - else - { - $db->rollback(); - - if ($object->error) - { - $errmsg=$object->error; - } - else - { - foreach($object->errors as $error) - { - if ($errmsg) $errmsg.='
'; - $errmsg.=$error; - } - } - $action=''; - } - } - else - { - $db->rollback(); - } - } -} - -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer) -{ - $result=$object->fetch($rowid); - $result=$object->delete($user); - if ($result > 0) + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { - header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent); - exit; - } - else - { - $mesg=$adh->error; + $search=""; + $search_type=""; + $search_ref=""; + $search_lastname=""; + $search_firstname=""; + $search_login=""; + $search_note=""; + $search_amount=""; + $search_account=""; + $toselect=''; + $search_array_options=array(); } } - /* * View */ -$form = new Form($db); +$form=new Form($db); +$subscription=new Subscription($db); +$adherent=new Adherent($db); +$accountstatic=new Account($db); +$now=dol_now(); -llxHeader('',$langs->trans("SubscriptionCard"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); - - -dol_htmloutput_errors($errmsg); - - -if ($user->rights->adherent->cotisation->creer && $action == 'edit') +// List of subscriptions +$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo,"; +$sql.= " c.rowid as crowid, c.fk_type, c.subscription,"; +$sql.= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,"; +$sql.= " c.fk_bank as bank, c.note,"; +$sql.= " b.fk_account"; +$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; +$sql.= " WHERE d.rowid = c.fk_adherent"; +$sql.= " AND d.entity IN (".getEntity('adherent').")"; +if (isset($date_select) && $date_select != '') { - /******************************************** - * - * Subscription card in edit mode - * - ********************************************/ + $sql.= " AND c.dateadh >= '".$date_select."-01-01 00:00:00'"; + $sql.= " AND c.dateadh < '".($date_select+1)."-01-01 00:00:00'"; +} +if ($search_ref) +{ + if (is_numeric($search_ref)) $sql.= " AND (c.rowid = ".$db->escape($search_ref).")"; + else $sql.=" AND 1 = 2"; // Always wrong +} +if ($search_type) $sql.= natural_search(array('c.fk_type'), $search_type); +if ($search_lastname) $sql.= natural_search(array('d.lastname','d.societe'), $search_lastname); +if ($search_firstname) $sql.= natural_search(array('d.firstname'), $search_firstname); +if ($search_login) $sql.= natural_search('d.login', $search_login); +if ($search_note) $sql.= natural_search('c.note', $search_note); +if ($search_account > 0) $sql.= " AND b.fk_account = ".urldecode($search_account); +if ($search_amount) $sql.= natural_search('c.subscription', $search_amount, 1); - $object->fetch($rowid); - $result=$adh->fetch($object->fk_adherent); +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - $head = subscription_prepare_head($object); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; - print '
'; - print ''; - print ""; - print ""; - print "fk_bank."\">"; +$sql.= $db->order($sortfield,$sortorder); - dol_fiche_head($head, 'general', $langs->trans("Subscription"), 0, 'payment'); +// Count total nb of records with no order and no limits +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + if ($resql) $nbtotalofrecords = $db->num_rows($resql); + else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } +} +// Add limit +$sql.= $db->plimit($limit+1, $offset); - $linkback = ''.$langs->trans("BackToList").''; - - print "\n"; - print ''; - - // Ref - print ''; - print ''; - - // Member - $adh->ref=$adh->getFullName($langs); - print ''; - print ''; - print ''; - - // Date start subscription - print ''; - print ''; - - // Date end subscription - print ''; - print ''; - - // Amount - print ''; - - // Label - print ''; - - // Bank line - if (! empty($conf->banque->enabled)) - { - if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) - { - print ''; - } - } - - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'rowid', $linkback, 1); - print '
'.$langs->trans("Member").''.$adh->getNomUrl(1,0,'subscription').'
'.$langs->trans("DateSubscription").''; - print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1); - print '
'.$langs->trans("DateEndSubscription").''; - print $form->selectDate($object->datef, 'datesubend', 0, 0, 0, 'update', 1); - print '
'.$langs->trans("Amount").''; - print '
'.$langs->trans("Label").''; - print '
'.$langs->trans("BankTransactionLine").''; - if ($object->fk_bank) - { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); - print $bankline->getNomUrl(1,0,'showall'); - } - else - { - print $langs->trans("NoneF"); - } - print '
'; - - dol_fiche_end(); - - print '
'; - print ''; - print '       '; - print ''; - print '
'; - - print '
'; - print "\n"; +$result = $db->query($sql); +if (! $result) +{ + dol_print_error($db); + exit; } -if ($rowid && $action != 'edit') +$num = $db->num_rows($result); + +$arrayofselected=is_array($toselect)?$toselect:array(); + +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { - /******************************************** - * - * Subscription card in view mode - * - ********************************************/ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/adherents/subscription/card.php?id='.$id); + exit; +} - $result=$object->fetch($rowid); - $result=$adh->fetch($object->fk_adherent); +llxHeader('',$langs->trans("ListOfSubscriptions"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); - $head = subscription_prepare_head($object); +$i = 0; - dol_fiche_head($head, 'general', $langs->trans("Subscription"), -1, 'payment'); +$title=$langs->trans("ListOfSubscriptions"); +if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')'; - // Confirmation to delete subscription - if ($action == 'delete') - { - //$formquestion=array(); - //$formquestion['text']=''.$langs->trans("ThisWillAlsoDeleteBankRecord").''; - $text=$langs->trans("ConfirmDeleteSubscription"); - if (! empty($conf->banque->enabled) && ! empty($conf->global->ADHERENT_BANK_USE)) $text.='
'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord"); - print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("DeleteSubscription"),$text,"confirm_delete",$formquestion,0,1); - } +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($statut != '') $param.="&statut=".urlencode($statut); +if ($search_type) $param.="&search_type=".urlencode($search_type); +if ($date_select) $param.="&date_select=".urlencode($date_select); +if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); +if ($search_login) $param.="&search_login=".urlencode($search_login); +if ($search_acount) $param.="&search_account=".urlencode($search_account); +if ($search_amount) $param.="&search_amount=".urlencode($search_amount); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - print '
'; - print ''; +// List of mass actions available +$arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), +); +//if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); - $linkback = ''.$langs->trans("BackToList").''; +$newcardbutton=''; +if ($user->rights->adherent->cotisation->creer) +{ + $newcardbutton=''.$langs->trans('NewSubscription').''; + $newcardbutton.= ''; + $newcardbutton.= ''; +} - dol_banner_tab($object, 'rowid', $linkback, 1); +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; - print '
'; +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit); - print '
'; +$topicmail="Information"; +$modelmail="subscription"; +$objecttmp=new Subscription($db); +$trackid='sub'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - print ''; +if ($sall) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; +} - // Member - $adh->ref=$adh->getFullName($langs); - print ''; - print ''; - print ''; +$moreforfilter = ''; - // Date record - /*print ''; - print ''; - print '';*/ +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - // Date subscription - print ''; - print ''; - print ''; +print '
'; +print '
'.$langs->trans("Member").''.$adh->getNomUrl(1,0,'subscription').'
'.$langs->trans("DateSubscription").''.dol_print_date($object->datec,'dayhour').'
'.$langs->trans("DateSubscription").''.dol_print_date($object->dateh,'day').'
'."\n"; - // Date end subscription - print ''; - print ''; - print ''; - // Amount - print ''; +// Line for filters fields +print ''; - // Amount - print ''; +// Line numbering +if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) +{ + print ''; +} - // Bank line - if (! empty($conf->banque->enabled)) +// Ref +if (! empty($arrayfields['d.ref']['checked'])) +{ + print ''; +} + +// Type +if (! empty($arrayfields['d.fk_type']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.lastname']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.firstname']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.login']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['t.libelle']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.bank']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.date_debut']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.date_fin']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.amount']['checked'])) +{ + print ''; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (! empty($arrayfields['d.datec']['checked'])) +{ + print ''; +} +// Date modification +if (! empty($arrayfields['d.tms']['checked'])) +{ + print ''; +} + +// Action column +print ''; + +print "\n"; + + +print ''; +if (! empty($arrayfields['d.ref']['checked'])) +{ + print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"c.rowid",$param,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['d.fk_type']['checked'])) +{ + print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"c.fk_type",$param,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['d.lastname']['checked'])) +{ + print_liste_field_titre("LastName",$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['d.firstname']['checked'])) +{ + print_liste_field_titre("FirstName",$_SERVER["PHP_SELF"],"d.firstname",$param,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['d.login']['checked'])) +{ + print_liste_field_titre("Login",$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['t.libelle']['checked'])) +{ + print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"c.note",$param,"",'align="left"',$sortfield,$sortorder); +} +if (! empty($arrayfields['d.bank']['checked'])) +{ + print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"b.fk_account",$pram,"","",$sortfield,$sortorder); +} +if (! empty($arrayfields['d.date_debut']['checked'])) +{ + print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"c.dateadh",$param,"",'align="center"',$sortfield,$sortorder); +} +if (! empty($arrayfields['d.date_fin']['checked'])) +{ + print_liste_field_titre("DateEnd",$_SERVER["PHP_SELF"],"c.datef",$param,"",'align="center"',$sortfield,$sortorder); +} +if (! empty($arrayfields['d.amount']['checked'])) +{ + print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"c.subscription",$param,"",'align="right"',$sortfield,$sortorder); +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + +// Hook fields +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'],$_SERVER["PHP_SELF"],"d.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); +print "\n"; + + +$total=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($result); + $total+=$obj->subscription; + + $subscription->ref=$obj->crowid; + $subscription->id=$obj->crowid; + + $adherent->lastname=$obj->lastname; + $adherent->firstname=$obj->firstname; + $adherent->ref=$obj->rowid; + $adherent->id=$obj->rowid; + $adherent->statut=$obj->statut; + $adherent->login=$obj->login; + $adherent->photo=$obj->photo; + + $adht = new AdherentType($db); + $adht->fetch($obj->fk_type); + + print ''; + + // Ref + if (! empty($arrayfields['d.ref']['checked'])) { - if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) - { - print ''; - } + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Type + if (! empty($arrayfields['d.fk_type']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; } - print "
'.$langs->trans("DateEndSubscription").''.dol_print_date($object->datef,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans("Label").''.$object->note.'
 '; + print ''; + print ''; + print''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_comptes($search_account, 'search_account', 0, '', 1); + print '  '; + print ''; + print ''; + print ''; + print ''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'.$langs->trans("BankTransactionLine").''; - if ($object->fk_bank) - { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); - print $bankline->getNomUrl(1,0,'showall'); - } - else - { - print $langs->trans("NoneF"); - } - print '
'.$subscription->getNomUrl(1).''; + if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1); + print '
\n"; - print '
'; - - print '
'; - - dol_fiche_end(); - - /* - * Barre d'actions - * - */ - print '
'; - - if ($user->rights->adherent->cotisation->creer) + // Lastname + if (! empty($arrayfields['d.lastname']['checked'])) { - if (! $bankline->rappro) + $adherent->firstname = ''; + print ''.$adherent->getNomUrl(-1).''; + $adherent->firstname = $obj->firstname; + if (! $i) $totalarray['nbfield']++; + } + // Firstname + if (! empty($arrayfields['d.firstname']['checked'])) + { + print ''.$adherent->firstname.''; + if (! $i) $totalarray['nbfield']++; + } + + // Login + if (! empty($arrayfields['d.login']['checked'])) + { + print ''.$adherent->login.''; + if (! $i) $totalarray['nbfield']++; + } + + // Label + if (! empty($arrayfields['t.libelle']['checked'])) + { + print ''; + print dol_trunc($obj->note,128); + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Banque + if (! empty($arrayfields['d.bank']['checked'])) + { + print ""; + if ($obj->fk_account > 0) { - print '"; + $accountstatic->id=$obj->fk_account; + $accountstatic->fetch($obj->fk_account); + //$accountstatic->label=$obj->label; + print $accountstatic->getNomUrl(1); } + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + + // Date start + if (! empty($arrayfields['d.date_start']['checked'])) + { + print ''.dol_print_date($db->jdate($obj->dateadh),'day')."\n"; + if (! $i) $totalarray['nbfield']++; + } + // Date end + if (! empty($arrayfields['d.date_end']['checked'])) + { + print ''.dol_print_date($db->jdate($obj->datef),'day')."\n"; + if (! $i) $totalarray['nbfield']++; + } + // Price + if (! empty($arrayfields['d.amount']['checked'])) + { + print ''.price($obj->subscription).''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='d.amount'; + $totalarray['val']['d.amount'] += $obj->subscription; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['d.datec']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['d.tms']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print ''; + if (! $i) $totalarray['nbfield']++; + + print "\n"; + $i++; +} + +// Show total line +if (isset($totalarray['pos'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).''; else { - print '"; + if ($i == 1) + { + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + } + else print ''; } } - - // Supprimer - if ($user->rights->adherent->cotisation->creer) - { - print '\n"; - } - - print '
'; - - - print '
'; - print ''; // ancre - - // Documents generes - /* - $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id; - $genallowed = $user->rights->facture->lire; - $delallowed = $user->rights->facture->creer; - - print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - $somethingshown = $formfile->numoffiles; - */ - // Show links to link elements - //$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription')); - $somethingshown = $form->showLinkedObjectBlock($object, ''); - - // Show links to link elements - /*$linktoelem = $form->showLinkToObjectBlock($object,array('order')); - if ($linktoelem) print ($somethingshown?'':'
').$linktoelem; - */ - - print '
'; - - // List of actions on element - /* - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'invoice', $socid, 1); - */ - - print '
'; + print ''; } +// If no record found +if ($num == 0) +{ + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; +} + +$db->free($resql); + +$parameters=array('sql' => $sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ""; +print ''; +print ''; + + // End of page llxFooter(); $db->close();