From 5e47f17cd710b8159dfe7d8d3752ca6e3634001f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 17:36:14 +0100 Subject: [PATCH 01/12] Display fk_type in subscription --- htdocs/adherents/subscription/list.php | 52 ++++++++++++++++++++------ 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 730ff4e9854..7ef9b36487c 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -25,10 +25,11 @@ require '../../main.inc.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'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -$langs->load(array("members","companies")); +$langs->loadLangs(array("members","companies")); $action=GETPOST('action','aZ09'); $massaction=GETPOST('massaction','alpha'); @@ -38,6 +39,7 @@ $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'); @@ -74,10 +76,11 @@ $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("Type"), '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),*/ @@ -112,16 +115,17 @@ if (empty($reshook)) // 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 { - $search=""; - $search_ref=""; - $search_lastname=""; + $search=""; + $search_type=""; + $search_ref=""; + $search_lastname=""; $search_firstname=""; $search_login=""; - $search_note=""; + $search_note=""; $search_amount=""; $search_account=""; - $toselect=''; - $search_array_options=array(); + $toselect=''; + $search_array_options=array(); } } @@ -139,7 +143,7 @@ $now=dol_now(); // List of subscriptions $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo,"; -$sql.= " c.rowid as crowid, c.subscription,"; +$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"; @@ -157,6 +161,7 @@ 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); @@ -220,6 +225,7 @@ $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); @@ -297,6 +303,14 @@ if (! empty($arrayfields['d.ref']['checked'])) print ''; } +// Type +if (! empty($arrayfields['d.fk_type']['checked'])) +{ + print ''; + print ''; + print''; +} + if (! empty($arrayfields['d.lastname']['checked'])) { print ''; @@ -379,6 +393,10 @@ 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); @@ -441,7 +459,9 @@ while ($i < min($num, $limit)) $adherent->statut=$obj->statut; $adherent->login=$obj->login; $adherent->photo=$obj->photo; - + + $adht = new AdherentType($db); + $adht->fetch($obj->fk_type); print ''; @@ -451,6 +471,14 @@ while ($i < min($num, $limit)) print ''.$subscription->getNomUrl(1).''; if (! $i) $totalarray['nbfield']++; } + // Type + if (! empty($arrayfields['d.fk_type']['checked'])) + { + print ''; + if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1); + print ''; + if (! $i) $totalarray['nbfield']++; + } // Lastname if (! empty($arrayfields['d.lastname']['checked'])) @@ -568,8 +596,8 @@ if (isset($totalarray['pos'])) { if ($i == 1) { - if ($num < $limit) print ''.$langs->trans("Total").''; - else print ''.$langs->trans("Totalforthispage").''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; } else print ''; } From 65189aa4f01e43944b34405962982682310acc44 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 17:37:39 +0100 Subject: [PATCH 02/12] display / update adherent type --- htdocs/adherents/subscription/card.php | 872 +++++++++++++++---------- 1 file changed, 540 insertions(+), 332 deletions(-) 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(); From 829807b467e41a1b17c37996aff0fc3e3b98ae46 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 17:38:46 +0100 Subject: [PATCH 03/12] modify class to display save adherent type in subscription --- htdocs/adherents/class/subscription.class.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 29f1f94e683..65e8b3b33ec 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -55,6 +55,7 @@ class Subscription extends CommonObject /** * @var int ID */ + public $fk_type; public $fk_adherent; public $amount; @@ -102,8 +103,16 @@ class Subscription extends CommonObject $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, datec, dateadh, datef, subscription, note)"; - $sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate($this->datec)."',"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; + if ($this->fk_type == NULL) { +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + $member=new Adherent($this->db); + $result=$member->fetch($this->fk_adherent); + $type=$member->typeid; + } else { + $type=$this->fk_type; + } + $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->dateh)."',"; $sql.= " '".$this->db->idate($this->datef)."',"; $sql.= " ".$this->amount.","; @@ -147,7 +156,7 @@ class Subscription extends CommonObject */ function fetch($rowid) { - $sql ="SELECT rowid, fk_adherent, datec,"; + $sql ="SELECT rowid, fk_type, fk_adherent, datec,"; $sql.=" tms,"; $sql.=" dateadh as dateh,"; $sql.=" datef,"; @@ -166,7 +175,8 @@ class Subscription extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; - $this->fk_adherent = $obj->fk_adherent; + $this->fk_type = $obj->fk_type; + $this->fk_adherent = $obj->fk_adherent; $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->tms); $this->dateh = $this->db->jdate($obj->dateh); @@ -203,6 +213,7 @@ class Subscription extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; + $sql .= " fk_type = ".$this->fk_type.","; $sql .= " fk_adherent = ".$this->fk_adherent.","; $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; $sql .= " subscription = '".price2num($this->amount)."',"; From ee595ca9b5a7ca30232c6a964592ff49412b1e0a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 17:40:47 +0100 Subject: [PATCH 04/12] Update 9.0.0-10.0.0.sql --- htdocs/install/mysql/migration/9.0.0-10.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 0079e90f2ae..264f0cdfc6c 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -80,6 +80,7 @@ create table llx_mailing_unsubscribe ALTER TABLE llx_mailing_unsubscribe ADD UNIQUE uk_mailing_unsubscribe(email, entity, unsubscribegroup); ALTER TABLE llx_adherent ADD gender VARCHAR(10); +ALTER TABLE llx_subscription ADD fk_type int(11); -- Add url_id into unique index of bank_url ALTER TABLE llx_bank_url DROP INDEX uk_bank_url; From 389b44faa3c2f3cb48a781eb742be484cc1535a8 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 17:41:45 +0100 Subject: [PATCH 05/12] Update llx_subscription.sql --- htdocs/install/mysql/tables/llx_subscription.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_subscription.sql b/htdocs/install/mysql/tables/llx_subscription.sql index 8d220ed9059..cb53d9405e9 100644 --- a/htdocs/install/mysql/tables/llx_subscription.sql +++ b/htdocs/install/mysql/tables/llx_subscription.sql @@ -22,6 +22,7 @@ create table llx_subscription tms timestamp, datec datetime, fk_adherent integer, + fk_type integer, dateadh datetime, datef date, subscription double(24,8), From 7ebf3967cb786a3ee42013e63908ec9f7ab98c44 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 17:45:52 +0100 Subject: [PATCH 06/12] Update subscription.class.php --- htdocs/adherents/class/subscription.class.php | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 65e8b3b33ec..11dd80b90ee 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -104,15 +104,16 @@ class Subscription extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; - if ($this->fk_type == NULL) { + + if ($this->fk_type == NULL) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); - $type=$member->typeid; - } else { - $type=$this->fk_type; - } - $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; +$member=new Adherent($this->db); +$result=$member->fetch($this->fk_adherent); +$type=$member->typeid; +} else { +$type=$this->fk_type; +} + $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->dateh)."',"; $sql.= " '".$this->db->idate($this->datef)."',"; $sql.= " ".$this->amount.","; @@ -176,7 +177,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; $this->ref = $obj->rowid; $this->fk_type = $obj->fk_type; - $this->fk_adherent = $obj->fk_adherent; + $this->fk_adherent = $obj->fk_adherent; $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->tms); $this->dateh = $this->db->jdate($obj->dateh); @@ -213,7 +214,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; - $sql .= " fk_type = ".$this->fk_type.","; + $sql .= " fk_type = ".$this->fk_type.","; $sql .= " fk_adherent = ".$this->fk_adherent.","; $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; $sql .= " subscription = '".price2num($this->amount)."',"; From f6eebf0ed5be4bc2ac3407f503255bf4087e4e31 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 17:48:13 +0100 Subject: [PATCH 07/12] Update card.php --- htdocs/adherents/subscription/card.php | 37 +++++++++++++------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 7ef9b36487c..a8d7708dfd5 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -76,7 +76,7 @@ $fieldstosearchall = array( ); $arrayfields=array( 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'd.fk_type'=>array('label'=>$langs->trans("Type"), '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), @@ -115,17 +115,17 @@ if (empty($reshook)) // 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 { - $search=""; - $search_type=""; - $search_ref=""; - $search_lastname=""; - $search_firstname=""; - $search_login=""; - $search_note=""; - $search_amount=""; - $search_account=""; - $toselect=''; - $search_array_options=array(); + $search=""; + $search_type=""; + $search_ref=""; + $search_lastname=""; + $search_firstname=""; + $search_login=""; + $search_note=""; + $search_amount=""; + $search_account=""; + $toselect=''; + $search_array_options=array(); } } @@ -471,13 +471,14 @@ while ($i < min($num, $limit)) print ''.$subscription->getNomUrl(1).''; if (! $i) $totalarray['nbfield']++; } - // Type - if (! empty($arrayfields['d.fk_type']['checked'])) + + // Type + if (! empty($arrayfields['d.fk_type']['checked'])) { - print ''; - if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1); - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1); + print ''; + if (! $i) $totalarray['nbfield']++; } // Lastname From 65144235617e50371abcb3ec7df0b2dcd84cc8ce Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 18:08:14 +0100 Subject: [PATCH 08/12] Update card.php --- htdocs/adherents/subscription/card.php | 902 ++++++++++--------------- 1 file changed, 357 insertions(+), 545 deletions(-) diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index a8d7708dfd5..3faa6974c8f 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -1,7 +1,6 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2016 Laurent Destailleur +/* Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2018 Frédéric France * * 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 @@ -18,613 +17,426 @@ */ /** - * \file htdocs/adherents/subscription/list.php - * \ingroup member - * \brief list of subscription + * \file htdocs/adherents/subscription/card.php + * \ingroup member + * \brief Page to add/edit/remove a member 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'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (! empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +} -$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"; } +// Load translation files required by the page +$langs->loadLangs(array("companies","members","bills","users")); +$adh = new Adherent($db); +$adht = new AdherentType($db); $object = new Subscription($db); +$errmsg=''; -// 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); +$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'); -// fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('subscription'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); +if (! $user->rights->adherent->cotisation->lire) + accessforbidden(); -// 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'); +$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 /* - * Actions + * Actions */ -if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if ($cancel) $action=''; -$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_setnotes.inc.php'; // Must be include, not include_once -if (empty($reshook)) +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) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Charge objet actuel + $result=$object->fetch($rowid); + if ($result > 0) + { + $db->begin(); - // 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 + $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->fk_type=$_POST["typeid"]; + $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) { - $search=""; - $search_type=""; - $search_ref=""; - $search_lastname=""; - $search_firstname=""; - $search_login=""; - $search_note=""; - $search_amount=""; - $search_account=""; - $toselect=''; - $search_array_options=array(); + header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent); + exit; + } + else + { + $mesg=$adh->error; } } + /* * View */ -$form=new Form($db); -$subscription=new Subscription($db); -$adherent=new Adherent($db); -$accountstatic=new Account($db); +$form = new Form($db); -$now=dol_now(); -// 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 != '') +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') { - $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); + /******************************************** + * + * Subscription card in edit mode + * + ********************************************/ -// Add where from extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + $object->fetch($rowid); + $result=$adh->fetch($object->fk_adherent); -// 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; + $head = subscription_prepare_head($object); -$sql.= $db->order($sortfield,$sortorder); + print '
'; + print ''; + print ""; + print ""; + print "fk_bank."\">"; -// 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); + dol_fiche_head($head, 'general', $langs->trans("Subscription"), 0, 'payment'); -$result = $db->query($sql); -if (! $result) -{ - dol_print_error($db); - exit; -} + $linkback = ''.$langs->trans("BackToList").''; -$num = $db->num_rows($result); + print "\n"; + print ''; -$arrayofselected=is_array($toselect)?$toselect:array(); + // Ref + print ''; + print ''; -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) -{ - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/adherents/subscription/card.php?id='.$id); - exit; -} + // Type + print ''; + print ''; -llxHeader('',$langs->trans("ListOfSubscriptions"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); + // Member + $adh->ref=$adh->getFullName($langs); + print ''; + print ''; + print ''; -$i = 0; - -$title=$langs->trans("ListOfSubscriptions"); -if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')'; - -$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'; - -// 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); - -$newcardbutton=''; -if ($user->rights->adherent->cotisation->creer) -{ - $newcardbutton=''.$langs->trans('NewSubscription').''; - $newcardbutton.= ''; - $newcardbutton.= ''; -} - -print ''; -if ($optioncss != '') 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); - -$topicmail="Information"; -$modelmail="subscription"; -$objecttmp=new Subscription($db); -$trackid='sub'.$object->id; -include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - -if ($sall) -{ - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; -} - -$moreforfilter = ''; - -$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); - -print '
'; -print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'rowid', $linkback, 1); + print '
'.$langs->trans("Type").''; + print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type)); + print'
'.$langs->trans("Member").''.$adh->getNomUrl(1,0,'subscription').'
'."\n"; - - -// Line for filters fields -print ''; - -// Line numbering -if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) -{ - print ''; -} - -// 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 ''; -} + print ''; -if (! empty($arrayfields['d.bank']['checked'])) -{ - print ''; -} + print ''; -if (! empty($arrayfields['d.date_debut']['checked'])) -{ - print ''; -} + // Amount + print ''; -if (! empty($arrayfields['d.date_fin']['checked'])) -{ - print ''; -} + // Label + 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'])) + // Bank line + if (! empty($conf->banque->enabled)) { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Type - if (! empty($arrayfields['d.fk_type']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Lastname - if (! empty($arrayfields['d.lastname']['checked'])) - { - $adherent->firstname = ''; - print ''; - $adherent->firstname = $obj->firstname; - if (! $i) $totalarray['nbfield']++; - } - // Firstname - if (! empty($arrayfields['d.firstname']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Login - if (! empty($arrayfields['d.login']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Label - if (! empty($arrayfields['t.libelle']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Banque - if (! empty($arrayfields['d.bank']['checked'])) - { - print "'; } - print "\n"; - if (! $i) $totalarray['nbfield']++; } - // Date start - if (! empty($arrayfields['d.date_start']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } - // Date end - if (! empty($arrayfields['d.date_end']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } - // Price - if (! empty($arrayfields['d.amount']['checked'])) - { - print ''; - 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 ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['d.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; + print '
 '; - print ''; - print ''; - print''; - print ''; - print ''; - print ''; - print ''; + // Date start subscription + print '
'.$langs->trans("DateSubscription").''; + print $form->selectDate($object->dateh, 'datesub', 1, 1, 0, 'update', 1); print '
'; - print $form->select_comptes($search_account, 'search_account', 0, '', 1); + // Date end subscription + print '
'.$langs->trans("DateEndSubscription").''; + print $form->selectDate($object->datef, 'datesubend', 0, 0, 0, 'update', 1); print '
 
'.$langs->trans("Amount").''; + print '
 
'.$langs->trans("Label").''; + print '
'; - print ''; - print ''; - print ''; - print ''; -$searchpicto=$form->showFilterButtons(); -print $searchpicto; -print '
'.$subscription->getNomUrl(1).''; - if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1); - print ''.$adherent->getNomUrl(-1).''.$adherent->firstname.''.$adherent->login.''; - print dol_trunc($obj->note,128); - print '"; - if ($obj->fk_account > 0) + if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { - $accountstatic->id=$obj->fk_account; - $accountstatic->fetch($obj->fk_account); - //$accountstatic->label=$obj->label; - print $accountstatic->getNomUrl(1); + 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_print_date($db->jdate($obj->dateadh),'day')."'.dol_print_date($db->jdate($obj->datef),'day')."'.price($obj->subscription).''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - 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 '
'; - print "\n"; - $i++; + dol_fiche_end(); + + print '
'; + print ''; + print '       '; + print ''; + print '
'; + + print '
'; + print "\n"; } -// Show total line -if (isset($totalarray['pos'])) +if ($rowid && $action != 'edit') { - print ''; - $i=0; - while ($i < $totalarray['nbfield']) + /******************************************** + * + * Subscription card in view mode + * + ********************************************/ + + $result=$object->fetch($rowid); + $result=$adh->fetch($object->fk_adherent); + + $head = subscription_prepare_head($object); + + dol_fiche_head($head, 'general', $langs->trans("Subscription"), -1, 'payment'); + + // 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); + } + + print '
'; + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'rowid', $linkback, 1); + + print '
'; + + print '
'; + + print ''; + + // Type + print ''; + print ''; + print ''; + + // Member + $adh->ref=$adh->getFullName($langs); + print ''; + print ''; + print ''; + + // Date record + /*print ''; + print ''; + print '';*/ + + // Date subscription + print ''; + print ''; + print ''; + + // Date end subscription + print ''; + print ''; + print ''; + + // Amount + print ''; + + // Amount + print ''; + + // Bank line + if (! empty($conf->banque->enabled)) { - $i++; - if (! empty($totalarray['pos'][$i])) print ''; + if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) + { + print ''; + } + } + + print "
'.$langs->trans("Type").''; + if ( ! empty($object->fk_type) ) { + $adht->fetch($object->fk_type); + print $adht->getNomUrl(1); + } else { + print $langs->trans("NoType"); + } + 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').'
'.$langs->trans("DateEndSubscription").''.dol_print_date($object->datef,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans("Label").''.$object->note.'
'.price($totalarray['val'][$totalarray['pos'][$i]]).'
'.$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 '
\n"; + print '
'; + + print '
'; + + dol_fiche_end(); + + /* + * Barre d'actions + * + */ + print '
'; + + if ($user->rights->adherent->cotisation->creer) + { + if (! $bankline->rappro) + { + print '"; + } else { - if ($i == 1) - { - if ($num < $limit) print ''.$langs->trans("Total").''; - else print ''.$langs->trans("Totalforthispage").''; - } - else print ''; + print '"; } } - 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 '
'; } -// 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(); From 2f36354c8d88c4363d2915136bd534e0ed800416 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 18:09:25 +0100 Subject: [PATCH 09/12] Update list.php --- htdocs/adherents/subscription/list.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 7ef9b36487c..85c92196a73 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -76,7 +76,7 @@ $fieldstosearchall = array( ); $arrayfields=array( 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'd.fk_type'=>array('label'=>$langs->trans("Type"), '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), @@ -115,17 +115,17 @@ if (empty($reshook)) // 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 { - $search=""; - $search_type=""; - $search_ref=""; - $search_lastname=""; - $search_firstname=""; - $search_login=""; - $search_note=""; - $search_amount=""; - $search_account=""; - $toselect=''; - $search_array_options=array(); + $search=""; + $search_type=""; + $search_ref=""; + $search_lastname=""; + $search_firstname=""; + $search_login=""; + $search_note=""; + $search_amount=""; + $search_account=""; + $toselect=''; + $search_array_options=array(); } } From 3deec2c8c8a8cb9fae65bf8a975b003928629b1c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 18:58:08 +0100 Subject: [PATCH 10/12] Update card.php --- htdocs/adherents/subscription/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 3faa6974c8f..014806a2a2f 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -313,13 +313,13 @@ if ($rowid && $action != 'edit') print ''; print ''.$langs->trans("Type").''; print ''; - if ( ! empty($object->fk_type) ) { - $adht->fetch($object->fk_type); + if ( ! empty($object->fk_type) ) { + $adht->fetch($object->fk_type); print $adht->getNomUrl(1); } else { - print $langs->trans("NoType"); + print $langs->trans("NoType"); } - print ''; + print ''; // Member $adh->ref=$adh->getFullName($langs); From b05f6d82fa3f6e15fbf9fd952bf6de6af3ec4174 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 19:38:19 +0100 Subject: [PATCH 11/12] Update subscription.class.php --- htdocs/adherents/class/subscription.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 11dd80b90ee..96876eb82b6 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -105,7 +105,7 @@ class Subscription extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; - if ($this->fk_type == NULL) { + if ($this->fk_type == null) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; $member=new Adherent($this->db); $result=$member->fetch($this->fk_adherent); From a36cf5f2c7b83082d4351c979522a08449e243f5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 20:34:45 +0100 Subject: [PATCH 12/12] Update 9.0.0-10.0.0.sql --- htdocs/install/mysql/migration/9.0.0-10.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 264f0cdfc6c..385e13b1905 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -80,7 +80,7 @@ create table llx_mailing_unsubscribe ALTER TABLE llx_mailing_unsubscribe ADD UNIQUE uk_mailing_unsubscribe(email, entity, unsubscribegroup); ALTER TABLE llx_adherent ADD gender VARCHAR(10); -ALTER TABLE llx_subscription ADD fk_type int(11); +ALTER TABLE llx_subscription ADD fk_type integer(11); -- Add url_id into unique index of bank_url ALTER TABLE llx_bank_url DROP INDEX uk_bank_url;