From 65144235617e50371abcb3ec7df0b2dcd84cc8ce Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 17 Jan 2019 18:08:14 +0100 Subject: [PATCH] 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();