Manage membership expiration
This commit is contained in:
parent
4700fd467f
commit
03a944edf5
@ -77,6 +77,7 @@ if (!$res) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
|
||||
// load partnership libraries
|
||||
require_once __DIR__.'/class/partnership.class.php';
|
||||
@ -112,8 +113,9 @@ $pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Partnership($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$object = new Partnership($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$adherent = new Adherent($db);
|
||||
$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('partnershiplist')); // Note that conf->hooks_modules contains array
|
||||
|
||||
@ -123,9 +125,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
||||
|
||||
if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member')
|
||||
unset($object->fields['fk_soc']);
|
||||
else unset($object->fields['fk_member']);
|
||||
$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR;
|
||||
|
||||
if($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = '';
|
||||
|
||||
// Default sort order (if not yet defined by previous GETPOST)
|
||||
if (!$sortfield) {
|
||||
@ -148,6 +150,11 @@ foreach ($object->fields as $key => $val) {
|
||||
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
|
||||
}
|
||||
}
|
||||
$search_filter = GETPOST("search_filter", 'alpha');
|
||||
$filter = GETPOST("filter", 'alpha');
|
||||
if ($filter) {
|
||||
$search_filter = $filter; // For backward compatibility
|
||||
}
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
$fieldstosearchall = array();
|
||||
@ -229,6 +236,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
$toselect = '';
|
||||
$search_array_options = array();
|
||||
$search_filter = "";
|
||||
}
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
||||
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
|
||||
@ -263,6 +271,9 @@ $morecss = array();
|
||||
// --------------------------------------------------------------------
|
||||
$sql = 'SELECT ';
|
||||
$sql .= $object->getFieldList('t');
|
||||
if ($managedfor == 'member'){
|
||||
$sql .= ', d.datefin, d.fk_adherent_type, dty.subscription';
|
||||
}
|
||||
// Add fields from extrafields
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
@ -278,6 +289,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
|
||||
}
|
||||
if ($managedfor == 'member'){
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)";
|
||||
}
|
||||
// Add table from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
@ -287,6 +302,10 @@ if ($object->ismultientitymanaged == 1) {
|
||||
} else {
|
||||
$sql .= " WHERE 1 = 1";
|
||||
}
|
||||
if ($managedfor == 'member')
|
||||
$sql .= " AND fk_member > 0";
|
||||
else
|
||||
$sql .= " AND fk_soc > 0";
|
||||
foreach ($search as $key => $val) {
|
||||
if (array_key_exists($key, $object->fields)) {
|
||||
if ($key == 'status' && $search[$key] == -1) {
|
||||
@ -316,6 +335,17 @@ foreach ($search as $key => $val) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($managedfor == 'member'){
|
||||
if ($search_filter == 'withoutsubscription') {
|
||||
$sql .= " AND (d.datefin IS NULL OR dty.subscription = 0)";
|
||||
}
|
||||
if ($search_filter == 'uptodate') {
|
||||
$sql .= " AND (d.datefin >= '".$db->idate($now)."' OR dty.subscription = 0)";
|
||||
}
|
||||
if ($search_filter == 'outofdate') {
|
||||
$sql .= " AND (d.datefin < '".$db->idate($now)."' AND dty.subscription = 1)";
|
||||
}
|
||||
}
|
||||
if ($search_all) {
|
||||
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||
}
|
||||
@ -422,6 +452,9 @@ foreach ($search as $key => $val) {
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
if ($search_filter && $search_filter != '-1') {
|
||||
$param .= "&search_filter=".urlencode($search_filter);
|
||||
}
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
// Add $param from hooks
|
||||
@ -500,6 +533,12 @@ print '<div class="div-table-responsive">'; // You can use div-table-responsive-
|
||||
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
|
||||
|
||||
if ($managedfor == 'member'){
|
||||
$arrayfields['t.fk_member']['checked'] = 1;
|
||||
}
|
||||
else {
|
||||
$arrayfields['t.fk_soc']['checked'] = 1;
|
||||
}
|
||||
// Fields title search
|
||||
// --------------------------------------------------------------------
|
||||
print '<tr class="liste_titre">';
|
||||
@ -533,6 +572,13 @@ foreach ($object->fields as $key => $val) {
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
// End of subscription date
|
||||
if ($managedfor == 'member'){
|
||||
print '<td class="liste_titre center">';
|
||||
$selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate"));
|
||||
print $form->selectarray('search_filter', $selectarray, $search_filter);
|
||||
print '</td>';
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
|
||||
@ -566,6 +612,12 @@ foreach ($object->fields as $key => $val) {
|
||||
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
|
||||
}
|
||||
}
|
||||
// End of subscription date
|
||||
if ($managedfor == 'member'){
|
||||
$key = 'datefin';
|
||||
$cssforfield = 'center';
|
||||
print getTitleFieldOfList('SubscriptionEndDate', 0, $_SERVER['PHP_SELF'], 'd.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
@ -641,6 +693,33 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// End of subscription date
|
||||
if ($managedfor == 'member'){
|
||||
print '<td class="nowrap center">';
|
||||
$result = $adherent->fetch($object->fk_member);
|
||||
if($result){
|
||||
$datefin = $adherent->datefin;
|
||||
if ($datefin) {
|
||||
print dol_print_date($datefin, 'day');
|
||||
if ($adherent->hasDelay()) {
|
||||
$textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')';
|
||||
print " ".img_warning($langs->trans("SubscriptionLate").$textlate);
|
||||
}
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td class="nowrap left">';
|
||||
if ($adherent->subscription == 'yes') {
|
||||
print $langs->trans("SubscriptionNotReceived");
|
||||
if ($adherent->statut > 0) {
|
||||
print " ".img_warning();
|
||||
}
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
||||
// Fields from hook
|
||||
|
||||
@ -139,6 +139,7 @@ $usercanclose = $user->rights->partnership->write; // Used by the include of
|
||||
$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||
|
||||
|
||||
if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') accessforbidden();
|
||||
if (empty($conf->partnership->enabled)) accessforbidden();
|
||||
if (empty($permissiontoread)) accessforbidden();
|
||||
if ($action == 'edit' && empty($permissiontoadd)) accessforbidden();
|
||||
@ -283,7 +284,6 @@ if (empty($reshook)) {
|
||||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formproject = new FormProjets($db);
|
||||
|
||||
$title = $langs->trans("Partnership");
|
||||
llxHeader('', $title);
|
||||
@ -349,8 +349,6 @@ if ($socid) {
|
||||
|
||||
$params = '';
|
||||
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$societe->id.'&backtopage='.urlencode($backtopage), '', 1, $params);
|
||||
|
||||
print '<br>';
|
||||
} else {
|
||||
dol_print_error('', 'Parameter socid not defined');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user