--- /tmp/dsg/dolibarr/htdocs/adherents/github_agenda.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_agenda.php @@ -49,10 +49,13 @@ if (!$sortfield) $sortfield = 'a.datep,a.id'; if (!$sortorder) $sortorder = 'DESC'; -if (GETPOST('actioncode', 'array')) { +if (GETPOST('actioncode', 'array')) +{ $actioncode = GETPOST('actioncode', 'array', 3); if (!count($actioncode)) $actioncode = '0'; -} else { +} +else +{ $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -62,11 +65,12 @@ $object = new Adherent($db); $result = $object->fetch($id); -if ($result > 0) { +if ($result > 0) +{ $object->fetch_thirdparty(); - $adht = new AdherentType($db); - $result = $adht->fetch($object->typeid); + $adht = new AdherentType($db); + $result = $adht->fetch($object->typeid); } @@ -78,18 +82,21 @@ $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'); -if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } +if (empty($reshook)) +{ + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers - $actioncode = ''; - $search_agenda_label = ''; - } + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $actioncode = ''; + $search_agenda_label = ''; + } } @@ -105,7 +112,8 @@ /* * Customer and/or supplier category sheet */ -if ($object->id > 0) { +if ($object->id > 0) +{ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -118,7 +126,7 @@ if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = member_prepare_head($object); - print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user'); + dol_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user'); $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; @@ -133,34 +141,36 @@ print '</div>'; - print dol_get_fiche_end(); + dol_fiche_end(); - //print '<div class="tabsAction">'; - //print '</div>'; + //print '<div class="tabsAction">'; + //print '</div>'; $newcardbutton = ''; - if (!empty($conf->agenda->enabled)) { - $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); - } + if (!empty($conf->agenda->enabled)) + { + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); + } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - print '<br>'; + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) + { + print '<br>'; - $param = '&id='.$id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + $param = '&id='.$id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; - // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); - } + // TODO Replace this with same code than into list.php + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } } // End of page --- /tmp/dsg/dolibarr/htdocs/adherents/github_card.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_card.php @@ -4,9 +4,9 @@ * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2012 Marcos GarcÃa <marcosgdf@gmail.com> - * Copyright (C) 2012-2020 Philippe Grand <philippe.grand@atoo-net.com> + * Copyright (C) 2012-2018 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2015-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> - * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr> + * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * * 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 @@ -25,7 +25,7 @@ /** * \file htdocs/adherents/card.php * \ingroup member - * \brief Page of a member + * \brief Page of member */ require '../main.inc.php'; @@ -45,7 +45,7 @@ // Load translation files required by the page $langs->loadLangs(array("companies", "bills", "members", "users", "other", "paypal")); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); @@ -55,7 +55,8 @@ $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); -if (!empty($conf->mailmanspip->enabled)) { +if (!empty($conf->mailmanspip->enabled)) +{ include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; $langs->load('mailmanspip'); @@ -75,23 +76,26 @@ $object->getCanvas($id); $canvas = $object->canvas ? $object->canvas : GETPOST("canvas"); $objcanvas = null; -if (!empty($canvas)) { +if (!empty($canvas)) +{ require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('adherent', 'membercard', $canvas); } // Security check -$result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', 0); - -if ($id > 0) { +$result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas); + +if ($id > 0) +{ // Load member $result = $object->fetch($id); // Define variables to know what current user can do on users $canadduser = ($user->admin || $user->rights->user->user->creer); // Define variables to know what current user can do on properties of user linked to edited member - if ($object->user_id) { + if ($object->user_id) + { // $User is the user who edits, $object->user_id is the id of the related user in the edited member $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) || (($user->id != $object->user_id) && $user->rights->user->user->creer)); @@ -103,7 +107,8 @@ // Define variables to determine what the current user can do on the members $canaddmember = $user->rights->adherent->creer; // Define variables to determine what the current user can do on the properties of a member -if ($id) { +if ($id) +{ $caneditfieldmember = $user->rights->adherent->creer; } @@ -120,26 +125,34 @@ $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'); -if (empty($reshook)) { - if ($cancel) { - if (!empty($backtopage)) { +if (empty($reshook)) +{ + if ($cancel) + { + if (!empty($backtopage)) + { header("Location: ".$backtopage); exit; } $action = ''; } - if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { + if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) + { $error = 0; - if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only - if ($userid != $user->id && $userid != $object->user_id) { + if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only + { + if ($userid != $user->id && $userid != $object->user_id) + { $error++; setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); } } - if (!$error) { - if ($userid != $object->user_id) { // If link differs from currently in database + if (!$error) + { + if ($userid != $object->user_id) // If link differs from currently in database + { $result = $object->setUserId($userid); if ($result < 0) dol_print_error($object->db, $object->error); $action = ''; @@ -147,17 +160,22 @@ } } - if ($action == 'setsocid') { + if ($action == 'setsocid') + { $error = 0; - if (!$error) { - if ($socid != $object->socid) { // If link differs from currently in database + if (!$error) + { + if ($socid != $object->socid) // If link differs from currently in database + { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql .= " WHERE socid = ".((int) $socid); + $sql .= " WHERE socid = '".$socid."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); - if ($resql) { + if ($resql) + { $obj = $db->fetch_object($resql); - if ($obj && $obj->rowid > 0) { + if ($obj && $obj->rowid > 0) + { $othermember = new Adherent($db); $othermember->fetch($obj->rowid); $thirdparty = new Societe($db); @@ -167,7 +185,8 @@ } } - if (!$error) { + if (!$error) + { $result = $object->setThirdPartyId($socid); if ($result < 0) dol_print_error($object->db, $object->error); $action = ''; @@ -177,51 +196,54 @@ } // Create user from a member - if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) { - if ($result > 0) { + if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) + { + if ($result > 0) + { // Creation user $nuser = new User($db); - $tmpuser = dol_clone($object); - if (GETPOST('internalorexternal', 'aZ09') == 'internal') { - $tmpuser->fk_soc = 0; - } - - $result = $nuser->create_from_member($tmpuser, GETPOST('login', 'alphanohtml')); - - if ($result < 0) { + $result = $nuser->create_from_member($object, GETPOST('login', 'alphanohtml')); + + if ($result < 0) + { $langs->load("errors"); setEventMessages($langs->trans($nuser->error), null, 'errors'); - } else { - setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs'); - $action = ''; - } - } else { + } + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } // Create third party from a member - if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { - if ($result > 0) { + if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) + { + if ($result > 0) + { // User creation $company = new Societe($db); $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); - if ($result < 0) { + if ($result < 0) + { $langs->load("errors"); setEventMessages($langs->trans($company->error), null, 'errors'); setEventMessages($company->error, $company->errors, 'errors'); } - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'update' && !$cancel && $user->rights->adherent->creer) { + if ($action == 'update' && !$cancel && $user->rights->adherent->creer) + { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $birthdate = ''; - if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) + if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) { $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); } @@ -247,14 +269,16 @@ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors'); } // Check if the login already exists - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { if (empty($login)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors'); } } // Create new object - if ($result > 0 && !$error) { + if ($result > 0 && !$error) + { $object->oldcopy = clone $object; // Change values @@ -262,7 +286,7 @@ $object->firstname = trim(GETPOST("firstname", 'alphanohtml')); $object->lastname = trim(GETPOST("lastname", 'alphanohtml')); $object->gender = trim(GETPOST("gender", 'alphanohtml')); - $object->login = trim(GETPOST("login", 'alphanohtml')); + $object->login = trim(GETPOST("login", 'alpha')); $object->pass = trim(GETPOST("pass", 'alpha')); $object->societe = trim(GETPOST("societe", 'alphanohtml')); // deprecated @@ -307,27 +331,32 @@ // Check if we need to also synchronize user information $nosyncuser = 0; - if ($object->user_id) { // If linked to a user + if ($object->user_id) // If linked to a user + { if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser = 1; // Disable synchronizing } // Check if we need to also synchronize password information $nosyncuserpass = 0; - if ($object->user_id) { // If linked to a user + if ($object->user_id) // If linked to a user + { if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass = 1; // Disable synchronizing } $result = $object->update($user, 0, $nosyncuser, $nosyncuserpass); - if ($result >= 0 && !count($object->errors)) { + if ($result >= 0 && !count($object->errors)) + { $categories = GETPOST('memcats', 'array'); $object->setCategories($categories); // Logo/Photo save $dir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos'; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if ($file_OK) { - if (GETPOST('deletephoto')) { + if ($file_OK) + { + if (GETPOST('deletephoto')) + { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileimg = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo; $dirthumbs = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs'; @@ -335,23 +364,33 @@ dol_delete_dir_recursive($dirthumbs); } - if (image_format_supported($_FILES['photo']['name']) > 0) { + if (image_format_supported($_FILES['photo']['name']) > 0) + { dol_mkdir($dir); - if (@is_dir($dir)) { + if (@is_dir($dir)) + { $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { + if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) + { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); - } else { - // Create thumbs - $object->addThumbs($newfile); + } + else + { + // Create thumbs + $object->addThumbs($newfile); } } - } else { + } + else + { setEventMessages("ErrorBadImageFormat", null, 'errors'); } - } else { - switch ($_FILES['photo']['error']) { + } + else + { + switch ($_FILES['photo']['error']) + { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $errors[] = "ErrorFileSizeTooLarge"; @@ -362,32 +401,42 @@ } } - $rowid = $object->id; - $id = $object->id; + $rowid = $object->id; + $id = $object->id; $action = ''; - if (!empty($backtopage)) { + if (!empty($backtopage)) + { header("Location: ".$backtopage); exit; } - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } - } else { + } + else + { $action = 'edit'; } } - if ($action == 'add' && $user->rights->adherent->creer) { + if ($action == 'add' && $user->rights->adherent->creer) + { if ($canvas) $object->canvas = $canvas; $birthdate = ''; - if (GETPOSTISSET("birthday") && GETPOST("birthday") && GETPOSTISSET("birthmonth") && GETPOST("birthmonth") && GETPOSTISSET("birthyear") && GETPOST("birthyear")) { - $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); + if (isset($_POST["birthday"]) && $_POST["birthday"] + && isset($_POST["birthmonth"]) && $_POST["birthmonth"] + && isset($_POST["birthyear"]) && $_POST["birthyear"]) + { + $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); } $datesubscription = ''; - if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) { - $datesubscription = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", "int"), GETPOST("reyear", "int")); + if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) + { + $datesubscription = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } $typeid = GETPOST("typeid", 'int'); @@ -408,11 +457,12 @@ // $skype=GETPOST("member_skype", 'alpha'); // $twitter=GETPOST("member_twitter", 'alpha'); // $facebook=GETPOST("member_facebook", 'alpha'); - // $linkedin=GETPOST("member_linkedin", 'alpha'); + // $linkedin=GETPOST("member_linkedin", 'alpha'); $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); - $login = GETPOST("member_login", 'alphanohtml'); + $login = GETPOST("member_login", 'alpha'); $pass = GETPOST("password", 'alpha'); $photo = GETPOST("photo", 'alpha'); + //$comment=GETPOST("comment",'none'); $morphy = GETPOST("morphy", 'alphanohtml'); $public = GETPOST("public", 'alphanohtml'); @@ -469,11 +519,13 @@ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MemberNature")), null, 'errors'); } // Tests if the login already exists - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { if (empty($login)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors'); - } else { + } + else { $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; $result = $db->query($sql); if ($result) { @@ -517,12 +569,14 @@ $public = 0; if (isset($public)) $public = 1; - if (!$error) { + if (!$error) + { $db->begin(); // Email about right and login does not exist $result = $object->create($user); - if ($result > 0) { + if ($result > 0) + { // Foundation categories $memcats = GETPOST('memcats', 'array'); $object->setCategories($memcats); @@ -531,7 +585,9 @@ $rowid = $object->id; $id = $object->id; $action = ''; - } else { + } + else + { $db->rollback(); if ($object->error) { @@ -542,27 +598,36 @@ $action = 'create'; } - } else { + } + else { $action = 'create'; } } - if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { + if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') + { $result = $object->delete($id, $user); - if ($result > 0) { - if (!empty($backtopage)) { + if ($result > 0) + { + if (!empty($backtopage)) + { header("Location: ".$backtopage); exit; - } else { + } + else + { header("Location: list.php"); exit; } - } else { + } + else + { $errmesg = $object->error; } } - if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') { + if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') + { $error = 0; $db->begin(); @@ -572,9 +637,11 @@ $result = $object->validate($user); - if ($result >= 0 && !count($object->errors)) { + if ($result >= 0 && !count($object->errors)) + { // Send confirmation email (according to parameters of member type. Otherwise generic) - if ($object->email && GETPOST("send_mail")) { + if ($object->email && GETPOST("send_mail")) + { $subject = ''; $msg = ''; @@ -592,7 +659,8 @@ if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; } @@ -601,7 +669,8 @@ //fallback on the old configuration. setEventMessages('WarningMandatorySetupNotComplete', null, 'errors'); $error++; - } else { + } + else { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); @@ -610,13 +679,16 @@ $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - if ($result < 0) { + if ($result < 0) + { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } - } else { + } + else + { $error++; if ($object->error) { setEventMessages($object->error, $object->errors, 'errors'); @@ -625,25 +697,32 @@ } } - if (!$error) { + if (!$error) + { $db->commit(); - } else { + } + else + { $db->rollback(); } $action = ''; } - if ($user->rights->adherent->supprimer && $action == 'confirm_resign') { + if ($user->rights->adherent->supprimer && $action == 'confirm_resign') + { $error = 0; - if ($confirm == 'yes') { + if ($confirm == 'yes') + { $adht = new AdherentType($db); $adht->fetch($object->typeid); $result = $object->resiliate($user); - if ($result >= 0 && !count($object->errors)) { - if ($object->email && GETPOST("send_mail")) { + if ($result >= 0 && !count($object->errors)) + { + if ($object->email && GETPOST("send_mail")) + { $subject = ''; $msg = ''; @@ -661,7 +740,8 @@ if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; } @@ -670,7 +750,8 @@ //fallback on the old configuration. setEventMessages('WarningMandatorySetupNotComplete', null, 'errors'); $error++; - } else { + } + else { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); @@ -679,13 +760,16 @@ $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n"; $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - if ($result < 0) { + if ($result < 0) + { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } - } else { + } + else + { $error++; if ($object->error) { @@ -696,24 +780,31 @@ $action = ''; } } - if (!empty($backtopage) && !$error) { + if (!empty($backtopage) && !$error) + { header("Location: ".$backtopage); exit; } } // SPIP Management - if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') { - if (!count($object->errors)) { - if (!$mailmanspip->del_to_spip($object)) { + if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') + { + if (!count($object->errors)) + { + if (!$mailmanspip->del_to_spip($object)) + { setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors'); } } } - if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') { - if (!count($object->errors)) { - if (!$mailmanspip->add_to_spip($object)) { + if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') + { + if (!count($object->errors)) + { + if (!$mailmanspip->add_to_spip($object)) + { setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors'); } } @@ -750,23 +841,28 @@ $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) +{ // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (empty($object->error) && $id) { + if (empty($object->error) && $id) + { $object = new Adherent($db); $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template -} else { + $objcanvas->display_canvas($action); // Show template +} +else +{ // ----------------------------------------- // When used in standard mode // ----------------------------------------- - if ($action == 'create') { + if ($action == 'create') + { /* ************************************************************************** */ /* */ /* Creation mode */ @@ -777,28 +873,31 @@ // We set country_id, country_code and country for the selected country $object->country_id = GETPOST('country_id', 'int') ?GETPOST('country_id', 'int') : $mysoc->country_id; - if ($object->country_id) { + if ($object->country_id) + { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; } - if (!empty($socid)) { - $object = new Societe($db); - if ($socid > 0) $object->fetch($socid); - - if (!($object->id > 0)) { - $langs->load("errors"); - print($langs->trans('ErrorRecordNotFound')); - exit; - } - } + if (!empty($socid)) { + $object = new Societe($db); + if ($socid > 0) $object->fetch($socid); + + if (!($object->id > 0)) + { + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; + } + } $adht = new AdherentType($db); print load_fiche_titre($langs->trans("NewMember"), '', 'members'); - if ($conf->use_javascript_ajax) { + if ($conf->use_javascript_ajax) + { print "\n".'<script type="text/javascript" language="javascript">'; print 'jQuery(document).ready(function () { jQuery("#selectcountry_id").change(function() { @@ -834,18 +933,20 @@ print '<input type="hidden" name="socid" value="'.$socid.'">'; if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">'; - print dol_get_fiche_head(''); + dol_fiche_head(''); print '<table class="border centpercent">'; print '<tbody>'; // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="member_login" class="minwidth300" maxlength="50" value="'.(GETPOSTISSET("member_login") ? GETPOST("member_login", 'alphanohtml', 2) : $object->login).'" autofocus="autofocus"></td></tr>'; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="member_login" class="minwidth300" maxlength="50" value="'.(isset($_POST["member_login"]) ?GETPOST("member_login", 'alpha', 2) : $object->login).'" autofocus="autofocus"></td></tr>'; } // Password - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $generated_password = getRandomPassword(false); print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>'; @@ -855,9 +956,10 @@ // Type print '<tr><td class="fieldrequired">'.$langs->trans("MemberType").'</td><td>'; - $listetype = $adht->liste_array(1); - if (count($listetype)) { - print $form->selectarray("typeid", $listetype, (GETPOST('typeid', 'int') ? GETPOST('typeid', 'int') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0, '', 0, 0, 0, '', '', 1); + $listetype = $adht->liste_array(); + if (count($listetype)) + { + print $form->selectarray("typeid", $listetype, GETPOST('typeid', 'int') ?GETPOST('typeid', 'int') : $typeid, count($listetype) > 1 ? 1 : 0); } else { print '<font class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</font>'; } @@ -867,7 +969,7 @@ $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print '<tr><td class="fieldrequired">'.$langs->trans("MemberNature")."</td><td>\n"; - print $form->selectarray("morphy", $morphys, (GETPOST('morphy', 'alpha') ?GETPOST('morphy', 'alpha') : $object->morphy), 1, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray("morphy", $morphys, GETPOST('morphy', 'alpha') ?GETPOST('morphy', 'alpha') : $object->morphy, 1); print "</td>\n"; // Company @@ -875,7 +977,7 @@ // Civility print '<tr><td>'.$langs->trans("UserTitle").'</td><td>'; - print $formcompany->select_civility(GETPOST('civility_id', 'int') ? GETPOST('civility_id', 'int') : $object->civility_id, 'civility_id', 'maxwidth150', 1).'</td>'; + print $formcompany->select_civility(GETPOST('civility_id', 'int') ?GETPOST('civility_id', 'int') : $object->civility_id, 'civility_id').'</td>'; print '</tr>'; // Lastname @@ -889,8 +991,8 @@ // Gender print '<tr><td>'.$langs->trans("Gender").'</td>'; print '<td>'; - $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother")); - print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1, 0, 0, '', 0, 0, 0, '', '', 1); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1); print '</td></tr>'; // EMail @@ -917,11 +1019,15 @@ print '</td></tr>'; // State - if (empty($conf->global->MEMBER_DISABLE_STATE)) { + if (empty($conf->global->MEMBER_DISABLE_STATE)) + { print '<tr><td>'.$langs->trans('State').'</td><td>'; - if ($object->country_id) { + if ($object->country_id) + { print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOST('state_id', 'int') : $object->state_id, $object->country_code); - } else { + } + else + { print $countrynotdefined; } print '</td></tr>'; @@ -939,15 +1045,15 @@ print '<tr><td>'.$langs->trans("PhoneMobile").'</td>'; print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" size="20" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>'; - if (!empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; + if (!$value['active']) break; print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.(GETPOSTISSET('member_'.$key) ? GETPOST('member_'.$key, 'alpha') : $object->socialnetworks[$key]).'"></td></tr>'; } } - // Birth Date - print "<tr><td>".$langs->trans("DateOfBirth")."</td><td>\n"; + // Birth Date + print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n"; print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); print "</td></tr>\n"; @@ -957,10 +1063,11 @@ print "</td></tr>\n"; // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) + { print '<tr><td>'.$form->editfieldkey("Categories", 'memcats', '', $object, 0).'</td><td>'; $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, 'parent', null, null, 1); - print img_picto('', 'category').$form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print $form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, null, null, '100%'); print "</td></tr>"; } @@ -970,22 +1077,26 @@ print '<tbody>'; print "</table>\n"; - print dol_get_fiche_end(); + dol_fiche_end(); print '<div class="center">'; print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">'; print ' '; - if (!empty($backtopage)) { - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; - } else { - print '<input type="button" class="button button-cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; + if (!empty($backtopage)) + { + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'; + } + else + { + print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">'; } print '</div>'; print "</form>\n"; } - if ($action == 'edit') { + if ($action == 'edit') + { /******************************************** * * Edition mode @@ -1006,12 +1117,16 @@ // We set country_id, and country_code, country of the chosen country $country = GETPOST('country', 'int'); - if (!empty($country) || $object->country_id) { + if (!empty($country) || $object->country_id) + { $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country) ? $country : $object->country_id); $resql = $db->query($sql); - if ($resql) { + if ($resql) + { $obj = $db->fetch_object($resql); - } else { + } + else + { dol_print_error($db); } $object->country_id = $obj->rowid; @@ -1022,7 +1137,8 @@ $head = member_prepare_head($object); - if ($conf->use_javascript_ajax) { + if ($conf->use_javascript_ajax) + { print "\n".'<script type="text/javascript" language="javascript">'; print 'jQuery(document).ready(function () { jQuery("#selectcountry_id").change(function() { @@ -1059,7 +1175,7 @@ print '<input type="hidden" name="statut" value="'.$object->statut.'" />'; if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">'; - print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); + dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); print '<table class="border centpercent">'; @@ -1067,26 +1183,31 @@ print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur">'.$object->id.'</td></tr>'; // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="login" class="minwidth300" maxlength="50" value="'.(GETPOSTISSET("login") ? GETPOST("login", 'alphanohtml', 2) : $object->login).'"></td></tr>'; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="login" class="minwidth300" maxlength="50" value="'.(isset($_POST["login"]) ?GETPOST("login", 'alpha', 2) : $object->login).'"></td></tr>'; } // Password - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td><td><input type="password" name="pass" class="minwidth300" maxlength="50" value="'.(GETPOSTISSET("pass") ? GETPOST("pass", '', 2) : $object->pass).'"></td></tr>'; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td><td><input type="password" name="pass" class="minwidth300" maxlength="50" value="'.(isset($_POST["pass"]) ?GETPOST("pass", '', 2) : $object->pass).'"></td></tr>'; } // Morphy $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberNature").'</span></td><td>'; - print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy), 0, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy)); print "</td></tr>"; // Type print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>'; - if ($user->rights->adherent->creer) { - print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $object->typeid), 0, 0, 0, '', 0, 0, 0, '', '', 1); - } else { + if ($user->rights->adherent->creer) + { + print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $object->typeid)); + } + else + { print $adht->getNomUrl(1); print '<input type="hidden" name="typeid" value="'.$object->typeid.'">'; } @@ -1097,7 +1218,7 @@ // Civility print '<tr><td>'.$langs->trans("UserTitle").'</td><td>'; - print $formcompany->select_civility(GETPOSTISSET("civility_id") ? GETPOST("civility_id", 'alpha') : $object->civility_id, 'civility_id', 'maxwidth150', 1); + print $formcompany->select_civility(GETPOSTISSET("civility_id") ? GETPOST("civility_id", 'alpha') : $object->civility_id)."\n"; print '</td>'; print '</tr>'; @@ -1112,15 +1233,16 @@ // Gender print '<tr><td>'.$langs->trans("Gender").'</td>'; print '<td>'; - $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother")); - print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ? GETPOST('gender', 'alphanohtml') : $object->gender, 1, 0, 0, '', 0, 0, 0, '', '', 1); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ? GETPOST('gender', 'alphanohtml') : $object->gender, 1); print '</td></tr>'; // Photo print '<tr><td>'.$langs->trans("Photo").'</td>'; print '<td class="hideonsmartphone" valign="middle">'; print $form->showphoto('memberphoto', $object)."\n"; - if ($caneditfieldmember) { + if ($caneditfieldmember) + { if ($object->photo) print "<br>\n"; print '<table class="nobordernopadding">'; if ($object->photo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>'; @@ -1132,7 +1254,7 @@ // EMail print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED ? '<span class="fieldrequired">' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '</span>' : '').'</td>'; - print '<td>'.img_picto('', 'object_email').' <input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOSTISSET("member_email") ? GETPOST("member_email", '', 2) : $object->email).'"></td></tr>'; + print '<td>'.img_picto('', 'object_email').' <input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(isset($_POST["member_email"]) ?GETPOST("member_email", '', 2) : $object->email).'"></td></tr>'; // Address print '<tr><td>'.$langs->trans("Address").'</td><td>'; @@ -1149,14 +1271,15 @@ // Country //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined print '<tr><td>'.$langs->trans('Country').'</td><td>'; - print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id, 'country_id'); + print $form->select_country(isset($_POST["country_id"]) ? $_POST["country_id"] : $object->country_id, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print '</td></tr>'; // State - if (empty($conf->global->MEMBER_DISABLE_STATE)) { + if (empty($conf->global->MEMBER_DISABLE_STATE)) + { print '<tr><td>'.$langs->trans('State').'</td><td>'; - print $formcompany->select_state($object->state_id, GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id); + print $formcompany->select_state($object->state_id, isset($_POST["country_id"]) ?GETPOST("country_id") : $object->country_id); print '</td></tr>'; } @@ -1169,18 +1292,18 @@ print '<td>'.img_picto('', 'object_phoning').' <input type="text" name="phone_perso" value="'.(GETPOSTISSET("phone_perso") ? GETPOST("phone_perso") : $object->phone_perso).'"></td></tr>'; // Mobile phone - print '<tr><td>'.$langs->trans("PhoneMobile").'</td>'; + print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'</td>'; print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" value="'.(GETPOSTISSET("phone_mobile") ? GETPOST("phone_mobile") : $object->phone_mobile).'"></td></tr>'; - if (!empty($conf->socialnetworks->enabled)) { + if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if (!$value['active']) break; + if (!$value['active']) break; print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : $object->socialnetworks[$key]).'"></td></tr>'; } } - // Birth Date - print "<tr><td>".$langs->trans("DateOfBirth")."</td><td>\n"; + // Birth Date + print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n"; print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc'); print "</td></tr>\n"; @@ -1190,7 +1313,8 @@ print "</td></tr>\n"; // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) + { print '<tr><td>'.$form->editfieldkey("Categories", 'memcats', '', $object, 0).'</td>'; print '<td>'; $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1); @@ -1207,13 +1331,17 @@ } // Third party Dolibarr - if (!empty($conf->societe->enabled)) { + if (!empty($conf->societe->enabled)) + { print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td colspan="2" class="valeur">'; - if ($object->socid) { + if ($object->socid) + { $company = new Societe($db); $result = $company->fetch($object->socid); print $company->getNomUrl(1); - } else { + } + else + { print $langs->trans("NoThirdPartyAssociatedToMember"); } print '</td></tr>'; @@ -1221,27 +1349,30 @@ // Login Dolibarr print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td colspan="2" class="valeur">'; - if ($object->user_id) { + if ($object->user_id) + { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none'); - } else print $langs->trans("NoDolibarrAccess"); + } + else print $langs->trans("NoDolibarrAccess"); print '</td></tr>'; // Other attributes. Fields from hook formObjectOptions and Extrafields. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print '</table>'; - print dol_get_fiche_end(); + dol_fiche_end(); print '<div class="center">'; - print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">'; + print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; print ' '; - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '</div>'; print '</form>'; } - if ($id > 0 && $action != 'edit') { + if ($id > 0 && $action != 'edit') + { /* ************************************************************************** */ /* */ /* View mode */ @@ -1269,12 +1400,14 @@ */ $head = member_prepare_head($object); - print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user'); + dol_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user'); // Confirm create user - if ($action == 'create_user') { - $login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login); - if (empty($login)) { + if ($action == 'create_user') + { + $login = $object->login; + if (empty($login)) + { // Full firstname and name separated with a dot : firstname.name include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $login = dol_buildlogin($object->lastname, $object->firstname); @@ -1285,27 +1418,28 @@ $formquestion = array( array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login) ); - if (!empty($conf->societe->enabled) && $object->socid > 0) { - $object->fetch_thirdparty(); - $formquestion[] = array('label' => $langs->trans("UserWillBe"), 'type' => 'radio', 'name' => 'internalorexternal', 'default'=>'external', 'values' => array('external'=>$langs->trans("External").' - '.$langs->trans("LinkedToDolibarrThirdParty").' '.$object->thirdparty->getNomUrl(1, '', 0, 1), 'internal'=>$langs->trans("Internal"))); - } - $text = ''; - if (!empty($conf->societe->enabled) && $object->socid <= 0) { - $text .= $langs->trans("UserWillBeInternalUser").'<br>'; - } - $text .= $langs->trans("ConfirmCreateLogin"); + $text = $langs->trans("ConfirmCreateLogin").'<br>'; + if (!empty($conf->societe->enabled)) + { + if ($object->socid > 0) $text .= $langs->trans("UserWillBeExternalUser"); + else $text .= $langs->trans("UserWillBeInternalUser"); + } print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); } // Confirm create third party - if ($action == 'create_thirdparty') { + if ($action == 'create_thirdparty') + { $companyalias = ''; $fullname = $object->getFullName($langs); - if ($object->morphy == 'mor') { + if ($object->morphy == 'mor') + { $companyname = $object->company; if (!empty($fullname)) $companyalias = $fullname; - } else { + } + else + { $companyname = $fullname; if (!empty($object->company)) $companyalias = $object->company; } @@ -1320,7 +1454,8 @@ } // Confirm validate member - if ($action == 'valid') { + if ($action == 'valid') + { $langs->load("mails"); $adht = new AdherentType($db); @@ -1343,7 +1478,8 @@ if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; } @@ -1379,7 +1515,8 @@ } // Confirm terminate - if ($action == 'resign') { + if ($action == 'resign') + { $langs->load("mails"); $adht = new AdherentType($db); @@ -1402,7 +1539,8 @@ if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; } @@ -1433,18 +1571,21 @@ } // Confirm remove member - if ($action == 'delete') { + if ($action == 'delete') + { $formquestion = array(); if ($backtopage) $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1); } // Confirm add in spip - if ($action == 'add_spip') { + if ($action == 'add_spip') + { print $form->formconfirm("card.php?rowid=".$id, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip'); } // Confirm removed from spip - if ($action == 'del_spip') { + if ($action == 'del_spip') + { print $form->formconfirm("card.php?rowid=$id", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip'); } @@ -1456,15 +1597,16 @@ dol_banner_tab($object, 'rowid', $linkback); - print '<div class="fichecenter">'; - print '<div class="fichehalfleft">'; - - print '<div class="underbanner clearboth"></div>'; + print '<div class="fichecenter">'; + print '<div class="fichehalfleft">'; + + print '<div class="underbanner clearboth"></div>'; print '<table class="border tableforfield centpercent">'; // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>'; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.' </td></tr>'; } // Type @@ -1481,85 +1623,68 @@ print '</td></tr>'; // Company - print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>'; + print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>'; // Civility - print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'</td>'; + print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>'; print '</tr>'; // Password - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass); - if ($object->pass) { - print preg_replace('/./i', '*', $object->pass); - } else { - if ($user->admin) { - print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; - } else { - print $langs->trans("Hidden"); - } - } - if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) { - $langs->load("errors"); - $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); - print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); + if ($object->pass) print preg_replace('/./i', '*', $object->pass); + else + { + if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; + else print $langs->trans("Hidden"); + } + if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) + { + $langs->load("errors"); + $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); + print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); } print '</td></tr>'; } // Date end subscription print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">'; - if ($object->datefin) { + if ($object->datefin) + { print dol_print_date($object->datefin, 'day'); if ($object->hasDelay()) { print " ".img_warning($langs->trans("Late")); } - } else { - if ($object->need_subscription == 0) { - print $langs->trans("SubscriptionNotNeeded"); - } elseif (!$adht->subscription) { + } + else + { + if ($object->need_subscription == 0) + { + print $langs->trans("SubscriptionNotNeeded"); + } + elseif (!$adht->subscription) + { print $langs->trans("SubscriptionNotRecorded"); if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated - } else { + } + else + { print $langs->trans("SubscriptionNotReceived"); if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated } } print '</td></tr>'; - print '</table>'; - - print '</div>'; - - print '<div class="fichehalfright"><div class="ficheaddleft">'; - print '<div class="underbanner clearboth"></div>'; - - print '<table class="border tableforfield tableforfield" width="100%">'; - - // Birth Date - print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>'; - - // Public - print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>'; - - // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print '<tr><td>'.$langs->trans("Categories").'</td>'; - print '<td colspan="2">'; - print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1); - print '</td></tr>'; - } - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - // Third party Dolibarr - if (!empty($conf->societe->enabled)) { + if (!empty($conf->societe->enabled)) + { print '<tr><td>'; $editenable = $user->rights->adherent->creer; print $form->editfieldkey('LinkedToDolibarrThirdParty', 'thirdparty', '', $object, $editenable); print '</td><td colspan="2" class="valeur">'; - if ($action == 'editthirdparty') { + if ($action == 'editthirdparty') + { $htmlname = 'socid'; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">'; print '<input type="hidden" name="rowid" value="'.$object->id.'">'; @@ -1571,12 +1696,17 @@ print '</td>'; print '<td class="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '</tr></table></form>'; - } else { - if ($object->socid) { + } + else + { + if ($object->socid) + { $company = new Societe($db); $result = $company->fetch($object->socid); print $company->getNomUrl(1); - } else { + } + else + { print $langs->trans("NoThirdPartyAssociatedToMember"); } } @@ -1588,34 +1718,53 @@ $editenable = $user->rights->adherent->creer && $user->rights->user->user->creer; print $form->editfieldkey('LinkedToDolibarrUser', 'login', '', $object, $editenable); print '</td><td colspan="2" class="valeur">'; - if ($action == 'editlogin') { + if ($action == 'editlogin') + { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', ''); - } else { - if ($object->user_id) { - $linkeduser = new User($db); - $linkeduser->fetch($object->user_id); - print $linkeduser->getNomUrl(-1); - } else { - print $langs->trans("NoDolibarrAccess"); - } + } + else + { + if ($object->user_id) + { + $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none'); + } + else print $langs->trans("NoDolibarrAccess"); } print '</td></tr>'; - //VCard - print '<tr><td>'; - print $langs->trans("VCard").'</td><td colspan="3">'; - print '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'">'; - print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"'); - print $langs->trans("Download"); - print '</a>'; - print '</td></tr>'; + print '</table>'; + + print '</div>'; + + print '<div class="fichehalfright"><div class="ficheaddleft">'; + print '<div class="underbanner clearboth"></div>'; + + print '<table class="border tableforfield tableforfield" width="100%">'; + + // Birth Date + print '<tr><td class="titlefield">'.$langs->trans("DateToBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>'; + + // Public + print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>'; + + // Categories + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) + { + print '<tr><td>'.$langs->trans("Categories").'</td>'; + print '<td colspan="2">'; + print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1); + print '</td></tr>'; + } + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print "</table>\n"; print "</div></div></div>\n"; - print '<div style="clear:both"></div>'; - - print dol_get_fiche_end(); + print '<div style="clear:both"></div>'; + + dol_fiche_end(); /* @@ -1626,7 +1775,8 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been if (empty($reshook)) { - if ($action != 'editlogin' && $action != 'editthirdparty') { + if ($action != 'editlogin' && $action != 'editthirdparty') + { // Send if (empty($user->socid)) { if ($object->statut == 1) { @@ -1655,82 +1805,112 @@ }*/ // Modify - if ($user->rights->adherent->creer) { + if ($user->rights->adherent->creer) + { print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=edit">'.$langs->trans("Modify")."</a></div>"; - } else { + } + else + { print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Modify").'</font></div>'; } // Validate - if ($object->statut == -1) { - if ($user->rights->adherent->creer) { + if ($object->statut == -1) + { + if ($user->rights->adherent->creer) + { print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=valid">'.$langs->trans("Validate")."</a></div>\n"; - } else { + } + else + { print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</font></div>'; } } // Reactivate - if ($object->statut == 0) { - if ($user->rights->adherent->creer) { + if ($object->statut == 0) + { + if ($user->rights->adherent->creer) + { print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=valid">'.$langs->trans("Reenable")."</a></div>\n"; - } else { + } + else + { print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Reenable")."</font></div>"; } } // Terminate - if ($object->statut >= 1) { - if ($user->rights->adherent->supprimer) { + if ($object->statut >= 1) + { + if ($user->rights->adherent->supprimer) + { print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$id.'&action=resign">'.$langs->trans("Resiliate")."</a></div>\n"; - } else { + } + else + { print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Resiliate")."</font></div>"; } } // Create third party - if (!empty($conf->societe->enabled) && !$object->socid) { - if ($user->rights->societe->creer) { + if (!empty($conf->societe->enabled) && !$object->socid) + { + if ($user->rights->societe->creer) + { if ($object->statut != -1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrThirdParty").'</a></div>'; - } else { + } + else + { print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrThirdParty")."</font></div>"; } } // Create user - if (!$user->socid && !$object->user_id) { - if ($user->rights->user->user->creer) { + if (!$user->socid && !$object->user_id) + { + if ($user->rights->user->user->creer) + { if ($object->statut != -1) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrLogin").'</a></div>'; - } else { + } + else + { print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin")."</font></div>"; } } + // Delete + if ($user->rights->adherent->supprimer) + { + print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete">'.$langs->trans("Delete")."</a></div>\n"; + } + else + { + print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Delete")."</font></div>"; + } + // Action SPIP - if (!empty($conf->mailmanspip->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) { + if (!empty($conf->mailmanspip->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) + { $isinspip = $mailmanspip->is_in_spip($object); - if ($isinspip == 1) { + if ($isinspip == 1) + { print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=del_spip">'.$langs->trans("DeleteIntoSpip")."</a></div>\n"; } - if ($isinspip == 0) { + if ($isinspip == 0) + { print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=add_spip">'.$langs->trans("AddIntoSpip")."</a></div>\n"; } } - - // Delete - if ($user->rights->adherent->supprimer) { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>\n"; - } else { - print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Delete")."</font></div>"; - } } } print '</div>'; - if ($isinspip == -1) { + if ($isinspip == -1) + { print '<br><br><font class="error">'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.'</font>'; } @@ -1740,7 +1920,8 @@ $action = 'presend'; } - if ($action != 'presend') { + if ($action != 'presend') + { print '<div class="fichecenter"><div class="fichehalfleft">'; print '<a name="builddoc"></a>'; // ancre @@ -1753,7 +1934,7 @@ $genallowed = $user->rights->adherent->lire; $delallowed = $user->rights->adherent->creer; - print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object); + print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object); $somethingshown = $formfile->numoffiles; // Show links to link elements @@ -1765,10 +1946,11 @@ if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem; */ - // Show online payment link + // Shon online payment link $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); - if ($useonlinepayment) { + if ($useonlinepayment) + { print '<br>'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; @@ -1784,7 +1966,7 @@ $morehtmlright .= '</a>'; // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright); --- /tmp/dsg/dolibarr/htdocs/adherents/github_document.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_document.php @@ -37,9 +37,8 @@ $langs->loadLangs(array("companies", "members", "other")); -$id = GETPOSTISSET('id') ? GETPOST('id', 'int') : GETPOST('rowid', 'int'); -$ref = GETPOST('ref', 'alphanohtml'); -$action = GETPOST('action', 'aZ09'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Security check @@ -61,8 +60,9 @@ $form = new Form($db); $object = new Adherent($db); $membert = new AdherentType($db); -$result = $object->fetch($id, $ref); -if ($result < 0) { +$result = $object->fetch($id); +if ($result < 0) +{ dol_print_error($db); exit; } @@ -86,57 +86,61 @@ $helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros"; llxHeader("", $title, $helpurl); -if ($id > 0) { - $result = $membert->fetch($object->typeid); - if ($result > 0) { +if ($id > 0) +{ + $result = $membert->fetch($object->typeid); + if ($result > 0) + { // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $totalsize = 0; - foreach ($filearray as $key => $file) { + foreach ($filearray as $key => $file) + { $totalsize += $file['size']; } - if (!empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = member_prepare_head($object); - print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user'); + dol_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user'); - $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; + $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; - dol_banner_tab($object, 'rowid', $linkback); + dol_banner_tab($object, 'rowid', $linkback); - print '<div class="fichecenter">'; + print '<div class="fichecenter">'; - print '<div class="underbanner clearboth"></div>'; + print '<div class="underbanner clearboth"></div>'; print '<table class="border tableforfield centpercent">'; $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.' </td></tr>'; - } + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.' </td></tr>'; + } - // Type - print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n"; + // Type + print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n"; - // Morphy - print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>'; - /*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">'; + // Morphy + print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>'; + /*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">'; print $form->showphoto('memberphoto',$object); print '</td>';*/ - print '</tr>'; + print '</tr>'; - // Company - print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>'; + // Company + print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>'; - // Civility - print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>'; - print '</tr>'; + // Civility + print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>'; + print '</tr>'; - // Number of Attached Files + // Number of Attached Files print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; //Total Size Of Attached Files @@ -146,7 +150,7 @@ print '</div>'; - print dol_get_fiche_end(); + dol_fiche_end(); $modulepart = 'member'; $permission = $user->rights->adherent->creer; @@ -154,11 +158,15 @@ $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; print "<br><br>"; - } else { + } + else + { dol_print_error($db); } -} else { - $langs->load("errors"); +} +else +{ + $langs->load("errors"); print $langs->trans("ErrorRecordNotFound"); } --- /tmp/dsg/dolibarr/htdocs/adherents/github_htpasswd.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_htpasswd.php @@ -40,11 +40,13 @@ if (empty($sortorder)) { $sortorder = "ASC"; } if (empty($sortfield)) { $sortfield = "d.login"; } -if (!isset($statut)) { +if (!isset($statut)) +{ $statut = 1; } -if (!isset($cotis)) { +if (!isset($cotis)) +{ // by default, members must be up to date of subscription $cotis = 1; } @@ -53,28 +55,33 @@ $sql = "SELECT d.login, d.pass, d.datefin"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d "; $sql .= " WHERE d.statut = ".$statut; -if ($cotis == 1) { +if ($cotis == 1) +{ $sql .= " AND datefin > '".$db->idate($now)."'"; } $sql .= $db->order($sortfield, $sortorder); //$sql.=$db->plimit($conf->liste_limit, $offset); $resql = $db->query($sql); -if ($resql) { +if ($resql) +{ $num = $db->num_rows($resql); $i = 0; print_barre_liste($langs->trans("HTPasswordExport"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0); print "<hr>\n"; - while ($i < $num) { + while ($i < $num) + { $objp = $db->fetch_object($result); $htpass = crypt($objp->pass, makesalt()); print $objp->login.":".$htpass."<br>\n"; $i++; } print "<hr>\n"; -} else { +} +else +{ dol_print_error($db); } --- /tmp/dsg/dolibarr/htdocs/adherents/github_index.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_index.php @@ -73,10 +73,12 @@ dol_syslog("index.php::select nb of members per type", LOG_DEBUG); $result = $db->query($sql); -if ($result) { +if ($result) +{ $num = $db->num_rows($result); $i = 0; - while ($i < $num) { + while ($i < $num) + { $objp = $db->fetch_object($result); $adhtype = new AdherentType($db); @@ -108,10 +110,12 @@ dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); $result = $db->query($sql); -if ($result) { +if ($result) +{ $num = $db->num_rows($result); $i = 0; - while ($i < $num) { + while ($i < $num) + { $objp = $db->fetch_object($result); $MemberUpToDate[$objp->fk_adherent_type] = $objp->somme; $i++; @@ -123,31 +127,35 @@ print '<div class="fichecenter"><div class="fichethirdleft">'; -if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo - // Search contact/address - if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { - $listofsearchfields['search_member'] = array('text'=>'Member'); - } - - if (count($listofsearchfields)) { - print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; - print '<input type="hidden" name="token" value="'.newToken().'">'; - print '<div class="div-table-responsive-no-min">'; - print '<table class="noborder nohover centpercent">'; - $i = 0; - foreach ($listofsearchfields as $key => $value) { - if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; - print '<tr class="oddeven">'; - print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; - if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; - print '</tr>'; - $i++; - } - print '</table>'; - print '</div>'; - print '</form>'; - print '<br>'; - } +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +{ + // Search contact/address + if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) + { + $listofsearchfields['search_member'] = array('text'=>'Member'); + } + + if (count($listofsearchfields)) + { + print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; + print '<div class="div-table-responsive-no-min">'; + print '<table class="noborder nohover centpercent">'; + $i = 0; + foreach ($listofsearchfields as $key => $value) + { + if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; + print '<tr class="oddeven">'; + print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; + if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; + print '</tr>'; + $i++; + } + print '</table>'; + print '</div>'; + print '</form>'; + print '<br>'; + } } @@ -155,56 +163,58 @@ * Statistics */ -if ($conf->use_javascript_ajax) { +if ($conf->use_javascript_ajax) +{ print '<div class="div-table-responsive-no-min">'; print '<table class="noborder nohover centpercent">'; - print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; - print '<tr><td class="center" colspan="2">'; - - $SommeA = 0; - $SommeB = 0; - $SommeC = 0; - $SommeD = 0; - $total = 0; - $dataval = array(); - $i = 0; - foreach ($AdherentType as $key => $adhtype) { - $dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0); - $dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0); - $dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0); - $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); - $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; - $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; - $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; - $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; - $i++; - } - $total = $SommeA + $SommeB + $SommeC + $SommeD; - $dataseries = array(); - $dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), round($SommeB)); - $dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), round($SommeC)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); - $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); - - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); - - print '</td></tr>'; - print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">'; - print $SommeA + $SommeB + $SommeC + $SommeD; - print '</td></tr>'; - print '</table>'; - print '</div>'; + print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; + print '<tr><td class="center" colspan="2">'; + + $SommeA = 0; + $SommeB = 0; + $SommeC = 0; + $SommeD = 0; + $total = 0; + $dataval = array(); + $i = 0; + foreach ($AdherentType as $key => $adhtype) + { + $dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0); + $dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0); + $dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0); + $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); + $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; + $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; + $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; + $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + $i++; + } + $total = $SommeA + $SommeB + $SommeC + $SommeD; + $dataseries = array(); + $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB)); + $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); + $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); + + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('200'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total ? 0 : 1); + + print '</td></tr>'; + print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">'; + print $SommeA + $SommeB + $SommeC + $SommeD; + print '</td></tr>'; + print '</table>'; + print '</div>'; } print '<br>'; @@ -222,18 +232,20 @@ $result = $db->query($sql); -if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); - $year = dol_print_date($db->jdate($objp->dateh), "%Y"); - $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; - $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; - $tot += $objp->subscription; - $numb += 1; - $i++; - } +if ($result) +{ + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $year = dol_print_date($db->jdate($objp->dateh), "%Y"); + $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; + $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; + $tot += $objp->subscription; + $numb += 1; + $i++; + } } print '<div class="div-table-responsive-no-min">'; @@ -247,8 +259,10 @@ krsort($Total); $i = 0; -foreach ($Total as $key=>$value) { - if ($i >= 8) { +foreach ($Total as $key=>$value) +{ + if ($i >= 8) + { print '<tr class="oddeven">'; print "<td>...</td>"; print "<td class=\"right\"></td>"; @@ -258,12 +272,12 @@ break; } print '<tr class="oddeven">'; - print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>"; - print "<td class=\"right\">".$Number[$key]."</td>"; - print "<td class=\"right\">".price($value)."</td>"; - print "<td class=\"right\">".price(price2num($value / $Number[$key], 'MT'))."</td>"; - print "</tr>\n"; - $i++; + print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>"; + print "<td class=\"right\">".$Number[$key]."</td>"; + print "<td class=\"right\">".price($value)."</td>"; + print "<td class=\"right\">".price(price2num($value / $Number[$key], 'MT'))."</td>"; + print "</tr>\n"; + $i++; } // Total @@ -282,12 +296,11 @@ /* * Latest modified members */ -$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; - -$sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; -$sql .= " a.gender, a.email, a.photo, a.morphy,"; -$sql .= " a.tms as datem, a.datefin as date_end_subscription,"; -$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription"; +$max = 5; + +$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; +$sql .= " a.tms as datem, datefin as date_end_subscription,"; +$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; $sql .= " WHERE a.entity IN (".getEntity('adherent').")"; $sql .= " AND a.fk_adherent_type = ta.rowid"; @@ -295,29 +308,89 @@ $sql .= $db->plimit($max, 0); $resql = $db->query($sql); -if ($resql) { +if ($resql) +{ print '<div class="div-table-responsive-no-min">'; print '<table class="noborder centpercent">'; print '<tr class="liste_titre">'; print '<th colspan="4">'.$langs->trans("LastMembersModified", $max).'</th></tr>'; $num = $db->num_rows($resql); - if ($num) { + if ($num) + { $i = 0; - while ($i < $num) { + while ($i < $num) + { $obj = $db->fetch_object($resql); - + print '<tr class="oddeven">'; $staticmember->id = $obj->rowid; - $staticmember->ref = $obj->rowid; $staticmember->lastname = $obj->lastname; $staticmember->firstname = $obj->firstname; - $staticmember->gender = $obj->gender; - $staticmember->email = $obj->email; - $staticmember->photo = $obj->photo; - $staticmember->morphy = $obj->morphy; - $staticmember->statut = $obj->status; - $staticmember->need_subscription = $obj->need_subscription; - $staticmember->datefin = $db->jdate($obj->date_end_subscription); + if (!empty($obj->fk_soc)) + { + $staticmember->fk_soc = $obj->fk_soc; + $staticmember->fetch_thirdparty(); + $staticmember->name = $staticmember->thirdparty->name; + } + else + { + $staticmember->name = $obj->company; + } + $staticmember->ref = $staticmember->getFullName($langs); + $statictype->id = $obj->typeid; + $statictype->label = $obj->label; + print '<td class="nowraponall">'.$staticmember->getNomUrl(1, 32).'</td>'; + print '<td>'.$statictype->getNomUrl(1, 32).'</td>'; + print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>'; + print '<td class="right">'.$staticmember->LibStatut($obj->statut, ($obj->subscription == 'yes' ? 1 : 0), $db->jdate($obj->date_end_subscription), 3).'</td>'; + print '</tr>'; + $i++; + } + } + print "</table></div>"; + print "<br>"; +} +else +{ + dol_print_error($db); +} + + +/* + * Last modified subscriptions + */ +$max = 5; + +$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; +$sql .= " datefin as date_end_subscription,"; +$sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c"; +$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; +$sql .= " AND c.fk_adherent = a.rowid"; +$sql .= $db->order("c.tms", "DESC"); +$sql .= $db->plimit($max, 0); + +$resql = $db->query($sql); +if ($resql) +{ + print '<div class="div-table-responsive-no-min">'; + print '<table class="noborder centpercent">'; + print '<tr class="liste_titre">'; + print '<th colspan="5">'.$langs->trans("LastSubscriptionsModified", $max).'</th></tr>'; + + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + print '<tr class="oddeven">'; + $subscriptionstatic->id = $obj->cid; + $subscriptionstatic->ref = $obj->cid; + $staticmember->id = $obj->rowid; + $staticmember->lastname = $obj->lastname; + $staticmember->firstname = $obj->firstname; if (!empty($obj->fk_soc)) { $staticmember->fk_soc = $obj->fk_soc; $staticmember->fetch_thirdparty(); @@ -325,82 +398,9 @@ } else { $staticmember->name = $obj->company; } - - $statictype->id = $obj->typeid; - $statictype->label = $obj->label; - $statictype->subscription = $obj->need_subscription; - - print '<tr class="oddeven">'; - print '<td class="nowraponall">'.$staticmember->getNomUrl(-1, 32).'</td>'; - print '<td>'.$statictype->getNomUrl(1, 32).'</td>'; - print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>'; - print '<td class="right">'.$staticmember->getLibStatut(3).'</td>'; - print '</tr>'; - $i++; - } - } - print "</table></div>"; - print "<br>"; -} else { - dol_print_error($db); -} - - -/* - * Last modified subscriptions - */ -$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; - -$sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; -$sql .= " a.gender, a.email, a.photo, a.morphy,"; -$sql .= " a.datefin as date_end_subscription,"; -$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription,"; -$sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta, ".MAIN_DB_PREFIX."subscription as c"; -$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; -$sql .= " AND a.fk_adherent_type = ta.rowid"; -$sql .= " AND c.fk_adherent = a.rowid"; -$sql .= $db->order("c.tms", "DESC"); -$sql .= $db->plimit($max, 0); - -$resql = $db->query($sql); -if ($resql) { - print '<div class="div-table-responsive-no-min">'; - print '<table class="noborder centpercent">'; - print '<tr class="liste_titre">'; - print '<th colspan="5">'.$langs->trans("LastSubscriptionsModified", $max).'</th></tr>'; - - $num = $db->num_rows($resql); - if ($num) { - $i = 0; - while ($i < $num) { - $obj = $db->fetch_object($resql); - - $staticmember->id = $obj->rowid; - $staticmember->ref = $obj->rowid; - $staticmember->lastname = $obj->lastname; - $staticmember->firstname = $obj->firstname; - $staticmember->gender = $obj->gender; - $staticmember->email = $obj->email; - $staticmember->photo = $obj->photo; - $staticmember->morphy = $obj->morphy; - $staticmember->statut = $obj->status; - $staticmember->need_subscription = $obj->need_subscription; - $staticmember->datefin = $db->jdate($obj->date_end_subscription); - if (!empty($obj->fk_soc)) { - $staticmember->fk_soc = $obj->fk_soc; - $staticmember->fetch_thirdparty(); - $staticmember->name = $staticmember->thirdparty->name; - } else { - $staticmember->name = $obj->company; - } - - $subscriptionstatic->id = $obj->cid; - $subscriptionstatic->ref = $obj->cid; - - print '<tr class="oddeven">'; + $staticmember->ref = $staticmember->getFullName($langs); print '<td class="nowraponall">'.$subscriptionstatic->getNomUrl(1).'</td>'; - print '<td class="nowraponall">'.$staticmember->getNomUrl(-1, 32, 'subscription').'</td>'; + print '<td class="nowraponall">'.$staticmember->getNomUrl(1, 32, 'subscription').'</td>'; print '<td class="nowraponall">'.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).'</td>'; print '<td class="right">'.price($obj->subscription).'</td>'; //print '<td class="right">'.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).'</td>'; @@ -411,7 +411,9 @@ } print "</table></div>"; print "<br>"; -} else { +} +else +{ dol_print_error($db); } @@ -422,12 +424,13 @@ print '<tr class="liste_titre">'; print '<th>'.$langs->trans("MembersTypes").'</th>'; print '<th class=right>'.$langs->trans("MembersStatusToValid").'</th>'; -print '<th class=right>'.$langs->trans("OutOfDate").'</th>'; -print '<th class=right>'.$langs->trans("UpToDate").'</th>'; +print '<th class=right>'.$langs->trans("MenuMembersNotUpToDate").'</th>'; +print '<th class=right>'.$langs->trans("MenuMembersUpToDate").'</th>'; print '<th class=right>'.$langs->trans("MembersStatusResiliated").'</th>'; print "</tr>\n"; -foreach ($AdherentType as $key => $adhtype) { +foreach ($AdherentType as $key => $adhtype) +{ print '<tr class="oddeven">'; print '<td>'.$adhtype->getNomUrl(1, dol_size(32)).'</td>'; print '<td class="right">'.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0 ? $MemberToValidate[$key] : '').' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).'</td>'; --- /tmp/dsg/dolibarr/htdocs/adherents/github_ldap.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_ldap.php @@ -37,13 +37,15 @@ // Protection $socid = 0; -if ($user->socid > 0) { - $socid = $user->socid; +if ($user->socid > 0) +{ + $socid = $user->socid; } $object = new Adherent($db); $result = $object->fetch($rowid); -if (!$result) { +if (!$result) +{ dol_print_error($db, "Failed to get adherent: ".$object->error); exit; } @@ -53,11 +55,13 @@ * Actions */ -if ($action == 'dolibarr2ldap') { +if ($action == 'dolibarr2ldap') +{ $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) { + if ($result > 0) + { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); $olddn = $dn; // We can say that old dn = dn as we force synchro @@ -67,7 +71,8 @@ if ($result >= 0) { setEventMessages($langs->trans("MemberSynchronized"), null, 'mesgs'); - } else { + } + else { setEventMessages($ldap->error, $ldap->errors, 'errors'); } } @@ -84,7 +89,7 @@ $head = member_prepare_head($object); -print dol_get_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user'); +dol_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user'); $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; @@ -99,7 +104,8 @@ print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.' </td></tr>'; // If there is a link to password not crypted, we show value in database here so we can compare because it is shown nowhere else -if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) { +if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) +{ print '<tr><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td>'; print '<td class="valeur">'.$object->pass.'</td>'; print "</tr>\n"; @@ -128,7 +134,7 @@ print '</div>'; -print dol_get_fiche_end(); +dol_fiche_end(); /* * Barre d'actions @@ -136,7 +142,8 @@ print '<div class="tabsAction">'; -if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') { +if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') +{ print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a></div>'; } @@ -159,34 +166,46 @@ // Lecture LDAP $ldap = new Ldap(); $result = $ldap->connect_bind(); -if ($result > 0) { +if ($result > 0) +{ $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; - if (empty($dn)) { - $langs->load("errors"); - print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>'; - } else { - $records = $ldap->getAttribute($dn, $search); - - //print_r($records); - - // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (!is_array($records)) { - print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; - } else { - $result = show_ldap_content($records, 0, $records['count'], true); - } - } else { - print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>'; - } - } + if (empty($dn)) + { + $langs->load("errors"); + print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>'; + } + else + { + $records = $ldap->getAttribute($dn, $search); + + //print_r($records); + + // Show tree + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) + { + if (!is_array($records)) + { + print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; + } + else + { + $result = show_ldap_content($records, 0, $records['count'], true); + } + } + else + { + print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>'; + } + } $ldap->unbind(); $ldap->close(); -} else { +} +else +{ setEventMessages($ldap->error, $ldap->errors, 'errors'); } --- /tmp/dsg/dolibarr/htdocs/adherents/github_list.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_list.php @@ -44,6 +44,8 @@ // Security check $result = restrictedArea($user, 'adherent'); +$filter = GETPOST("filter", 'alpha'); +$statut = GETPOST("statut", 'intcomma'); $search = GETPOST("search", 'alpha'); $search_ref = GETPOST("search_ref", 'alpha'); $search_lastname = GETPOST("search_lastname", 'alpha'); @@ -63,19 +65,12 @@ $search_type = GETPOST("search_type", 'alpha'); $search_email = GETPOST("search_email", 'alpha'); $search_categ = GETPOST("search_categ", 'int'); -$search_filter = GETPOST("search_filter", 'alpha'); -$search_status = GETPOST("search_status", 'intcomma'); $catid = GETPOST("catid", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); -$filter = GETPOST("filter", 'alpha'); -if ($filter) $search_filter = $filter; // For backward compatibility -$statut = GETPOST("statut", 'alpha'); -if ($statut != '') $search_status = $statut; // For backward compatibility - $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -if ($search_status < -1) $search_status = ''; +if ($statut < -1) $statut = ''; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -126,7 +121,7 @@ 'd.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0), 'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1), 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), - 'd.morphy'=>array('label'=>$langs->trans("MemberNature"), 'checked'=>1), + 'd.morphy'=>array('label'=>$langs->trans("MorPhy"), 'checked'=>1), 't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'd.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1), 'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0), @@ -146,7 +141,14 @@ 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) ); // Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} /* @@ -160,15 +162,14 @@ $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'); -if (empty($reshook)) { +if (empty($reshook)) +{ // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // 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 - $statut = ''; - $filter = ''; - + 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 = ""; @@ -189,40 +190,47 @@ $search_phone_mobile = ''; $search_morphy = ""; $search_categ = ""; - $search_filter = ""; - $search_status = ""; $catid = ""; $sall = ""; + $statut = ''; $toselect = ''; $search_array_options = array(); } // Close - if ($massaction == 'close' && $user->rights->adherent->creer) { - $tmpmember = new Adherent($db); - $error = 0; - $nbclose = 0; - - $db->begin(); - - foreach ($toselect as $idtoclose) { - $tmpmember->fetch($idtoclose); - $result = $tmpmember->resiliate($user); - - if ($result < 0 && !count($tmpmember->errors)) { - setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); - } else { - if ($result > 0) $nbclose++; - } - } - - if (!$error) { - setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); - - $db->commit(); - } else { - $db->rollback(); - } + if ($massaction == 'close' && $user->rights->adherent->creer) + { + $tmpmember = new Adherent($db); + $error = 0; + $nbclose = 0; + + $db->begin(); + + foreach ($toselect as $idtoclose) + { + $tmpmember->fetch($idtoclose); + $result = $tmpmember->resiliate($user); + + if ($result < 0 && !count($tmpmember->errors)) + { + setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); + } + else + { + if ($result > 0) $nbclose++; + } + } + + if (!$error) + { + setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); + + $db->commit(); + } + else + { + $db->rollback(); + } } // Mass actions @@ -277,22 +285,19 @@ $sql .= " AND d.entity IN (".getEntity('adherent').")"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_type > 0) $sql .= " AND t.rowid=".$db->escape($search_type); -if ($search_filter == 'withoutsubscription') $sql .= " AND (datefin IS NULL OR t.subscription = 0)"; -if ($search_filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; -if ($search_filter == 'outofdate') $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; -if ($search_status != '') $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")"; // Peut valoir un nombre ou liste de nombre separes par virgules -if ($search_ref) { +if ($statut != '') $sql .= " AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules +if ($search_ref) +{ if (is_numeric($search_ref)) $sql .= " AND (d.rowid = ".$db->escape($search_ref).")"; else $sql .= " AND 1 = 2"; // Always wrong } if ($search_civility) $sql .= natural_search("d.civility", $search_civility); if ($search_firstname) $sql .= natural_search("d.firstname", $search_firstname); if ($search_lastname) $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname); -if ($search_gender != '' && $search_gender != '-1') $sql .= natural_search("d.gender", $search_gender); +if ($search_gender != '' && $search_gender != '-1') $sql .= " AND d.gender = '".$search_gender."'"; if ($search_login) $sql .= natural_search("d.login", $search_login); if ($search_company) $sql .= natural_search("s.nom", $search_company); if ($search_email) $sql .= natural_search("d.email", $search_email); -if ($search_address) $sql .= natural_search("d.address", $search_address); if ($search_town) $sql .= natural_search("d.town", $search_town); if ($search_zip) $sql .= natural_search("d.zip", $search_zip); if ($search_state) $sql .= natural_search("state.nom", $search_state); @@ -300,6 +305,8 @@ if ($search_phone_perso) $sql .= natural_search("d.phone_perso", $search_phone_perso); if ($search_phone_mobile) $sql .= natural_search("d.phone_mobile", $search_phone_mobile); if ($search_country) $sql .= " AND d.country IN (".$search_country.')'; +if ($filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; +if ($filter == 'outofdate') $sql .= " AND ((datefin IS NULL OR datefin < '".$db->idate($now)."') AND t.subscription = 1)"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -313,11 +320,13 @@ // Count total nb of records with no order and no limits $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { +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 + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { $page = 0; $offset = 0; } @@ -327,7 +336,8 @@ dol_syslog("get list", LOG_DEBUG); $resql = $db->query($sql); -if (!$resql) { +if (!$resql) +{ dol_print_error($db); exit; } @@ -336,7 +346,8 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { +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/card.php?id='.$id); @@ -346,19 +357,22 @@ llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); $titre = $langs->trans("MembersList"); -if (GETPOSTISSET("search_status")) { - if ($search_status == '-1,1') { $titre = $langs->trans("MembersListQualified"); } - if ($search_status == '-1') { $titre = $langs->trans("MembersListToValid"); } - if ($search_status == '1' && $filter == '') { $titre = $langs->trans("MembersValidated"); } - if ($search_status == '1' && $filter == 'withoutsubscription') { $titre = $langs->trans("MembersWithSubscriptionToReceive"); } - if ($search_status == '1' && $filter == 'uptodate') { $titre = $langs->trans("MembersListUpToDate"); } - if ($search_status == '1' && $filter == 'outofdate') { $titre = $langs->trans("MembersListNotUpToDate"); } - if ($search_status == '0') { $titre = $langs->trans("MembersListResiliated"); } -} elseif ($action == 'search') { +if (GETPOSTISSET("statut")) +{ + if ($statut == '-1,1') { $titre = $langs->trans("MembersListQualified"); } + if ($statut == '-1') { $titre = $langs->trans("MembersListToValid"); } + if ($statut == '1' && !$filter) { $titre = $langs->trans("MembersListValid"); } + if ($statut == '1' && $filter == 'uptodate') { $titre = $langs->trans("MembersListUpToDate"); } + if ($statut == '1' && $filter == 'outofdate') { $titre = $langs->trans("MembersListNotUpToDate"); } + if ($statut == '0') { $titre = $langs->trans("MembersListResiliated"); } +} +elseif ($action == 'search') +{ $titre = $langs->trans("MembersListQualified"); } -if ($search_type > 0) { +if ($search_type > 0) +{ $membertype = new AdherentType($db); $result = $membertype->fetch(GETPOST("type", 'int')); $titre .= " (".$membertype->label.")"; @@ -368,6 +382,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($sall != "") $param .= "&sall=".urlencode($sall); +if ($statut != "") $param .= "&statut=".urlencode($statut); if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); if ($search_civility) $param .= "&search_civility=".urlencode($search_civility); if ($search_firstname) $param .= "&search_firstname=".urlencode($search_firstname); @@ -375,7 +390,6 @@ if ($search_gender) $param .= "&search_gender=".urlencode($search_gender); if ($search_login) $param .= "&search_login=".urlencode($search_login); if ($search_email) $param .= "&search_email=".urlencode($search_email); -if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); if ($search_company) $param .= "&search_company=".urlencode($search_company); if ($search_address != '') $param .= "&search_address=".urlencode($search_address); if ($search_town != '') $param .= "&search_town=".urlencode($search_town); @@ -385,8 +399,7 @@ if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone); if ($search_phone_perso != '') $param .= "&search_phone_perso=".urlencode($search_phone_perso); if ($search_phone_mobile != '') $param .= "&search_phone_mobile=".urlencode($search_phone_mobile); -if ($search_filter && $search_filter != '-1') $param .= "&search_filter=".urlencode($search_filter); -if ($search_status != "" && $search_status != '-1') $param .= "&search_status=".urlencode($search_status); +if ($filter) $param .= "&filter=".urlencode($filter); if ($search_type > 0) $param .= "&search_type=".urlencode($search_type); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -403,8 +416,9 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; -if ($user->rights->adherent->creer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); +if ($user->rights->adherent->creer) +{ + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); } print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; @@ -424,14 +438,16 @@ $trackid = 'mem'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) { +if ($sall) +{ foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>'; } // Filter on categories $moreforfilter = ''; -if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { +if (!empty($conf->categorie->enabled)) +{ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= $langs->trans('Categories').': '; @@ -442,7 +458,8 @@ $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (!empty($moreforfilter)) { +if (!empty($moreforfilter)) +{ print '<div class="liste_titre liste_titre_bydiv centpercent">'; print $moreforfilter; print '</div>'; @@ -460,103 +477,121 @@ print '<tr class="liste_titre_filter">'; // Line numbering -if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { +if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) +{ print '<td class="liste_titre"> </td>'; } // Ref -if (!empty($arrayfields['d.ref']['checked'])) { +if (!empty($arrayfields['d.ref']['checked'])) +{ print '<td class="liste_titre">'; print '<input class="flat maxwidth75imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '</td>'; } -if (!empty($arrayfields['d.civility']['checked'])) { +if (!empty($arrayfields['d.civility']['checked'])) +{ print '<td class="liste_titre left">'; print '<input class="flat maxwidth50imp" type="text" name="search_civility" value="'.dol_escape_htmltag($search_civility).'"></td>'; } -if (!empty($arrayfields['d.firstname']['checked'])) { +if (!empty($arrayfields['d.firstname']['checked'])) +{ print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_firstname" value="'.dol_escape_htmltag($search_firstname).'"></td>'; } -if (!empty($arrayfields['d.lastname']['checked'])) { +if (!empty($arrayfields['d.lastname']['checked'])) +{ print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'"></td>'; } -if (!empty($arrayfields['d.gender']['checked'])) { +if (!empty($arrayfields['d.gender']['checked'])) +{ print '<td class="liste_titre">'; - $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother")); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); print $form->selectarray('search_gender', $arraygender, $search_gender, 1); print '</td>'; } -if (!empty($arrayfields['d.company']['checked'])) { +if (!empty($arrayfields['d.company']['checked'])) +{ print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).'"></td>'; } -if (!empty($arrayfields['d.login']['checked'])) { +if (!empty($arrayfields['d.login']['checked'])) +{ print '<td class="liste_titre left">'; print '<input class="flat maxwidth75imp" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>'; } -if (!empty($arrayfields['d.morphy']['checked'])) { - print '<td class="liste_titre left">'; - print '</td>'; -} -if (!empty($arrayfields['t.libelle']['checked'])) { +if (!empty($arrayfields['d.morphy']['checked'])) +{ + print '<td class="liste_titre left">'; + print '</td>'; +} +if (!empty($arrayfields['t.libelle']['checked'])) +{ print '<td class="liste_titre">'; $listetype = $membertypestatic->liste_array(); print $form->selectarray("search_type", $listetype, $type, 1, 0, 0, '', 0, 32); print '</td>'; } -if (!empty($arrayfields['d.address']['checked'])) { - print '<td class="liste_titre left">'; - print '<input class="flat maxwidth75imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'"></td>'; -} - -if (!empty($arrayfields['d.zip']['checked'])) { - print '<td class="liste_titre left">'; - print '<input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'"></td>'; -} -if (!empty($arrayfields['d.town']['checked'])) { - print '<td class="liste_titre left">'; - print '<input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'"></td>'; +if (!empty($arrayfields['d.address']['checked'])) +{ + print '<td class="liste_titre left">'; + print '<input class="flat maxwidth75imp" type="text" name="search_address" value="'.$search_address.'"></td>'; +} + +if (!empty($arrayfields['d.zip']['checked'])) +{ + print '<td class="liste_titre left">'; + print '<input class="flat maxwidth50imp" type="text" name="search_zip" value="'.$search_zip.'"></td>'; +} +if (!empty($arrayfields['d.town']['checked'])) +{ + print '<td class="liste_titre left">'; + print '<input class="flat maxwidth75imp" type="text" name="search_town" value="'.$search_town.'"></td>'; } // State -if (!empty($arrayfields['state.nom']['checked'])) { +if (!empty($arrayfields['state.nom']['checked'])) +{ print '<td class="liste_titre">'; print '<input class="flat searchstring maxwidth75imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; print '</td>'; } // Country -if (!empty($arrayfields['country.code_iso']['checked'])) { +if (!empty($arrayfields['country.code_iso']['checked'])) +{ print '<td class="liste_titre center">'; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print '</td>'; } // Phone pro -if (!empty($arrayfields['d.phone']['checked'])) { - print '<td class="liste_titre left">'; - print '<input class="flat maxwidth75imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'"></td>'; +if (!empty($arrayfields['d.phone']['checked'])) +{ + print '<td class="liste_titre left">'; + print '<input class="flat maxwidth75imp" type="text" name="search_phone" value="'.$search_phone.'"></td>'; } // Phone perso -if (!empty($arrayfields['d.phone_perso']['checked'])) { - print '<td class="liste_titre left">'; - print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.dol_escape_htmltag($search_phone_perso).'"></td>'; +if (!empty($arrayfields['d.phone_perso']['checked'])) +{ + print '<td class="liste_titre left">'; + print '<input class="flat maxwidth50" type="text" name="search_phone_perso" value="'.$search_phone_perso.'"></td>'; } // Phone mobile -if (!empty($arrayfields['d.phone_mobile']['checked'])) { - print '<td class="liste_titre left">'; - print '<input class="flat maxwidth75imp" type="text" name="search_phone_mobile" value="'.dol_escape_htmltag($search_phone_mobile).'"></td>'; +if (!empty($arrayfields['d.phone_mobile']['checked'])) +{ + print '<td class="liste_titre left">'; + print '<input class="flat maxwidth75imp" type="text" name="search_phone_mobile" value="'.$search_phone_mobile.'"></td>'; } // Email -if (!empty($arrayfields['d.email']['checked'])) { - print '<td class="liste_titre left">'; - print '<input class="flat maxwidth75imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'"></td>'; -} -// End of subscription date -if (!empty($arrayfields['d.datefin']['checked'])) { - print '<td class="liste_titre left">'; - $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); - print $form->selectarray('search_filter', $selectarray, $search_filter); +if (!empty($arrayfields['d.email']['checked'])) +{ + print '<td class="liste_titre left">'; + print '<input class="flat maxwidth75imp" type="text" name="search_email" value="'.$search_email.'"></td>'; +} + +if (!empty($arrayfields['d.datefin']['checked'])) +{ + print '<td class="liste_titre left">'; print '</td>'; } // Extra fields @@ -567,29 +602,33 @@ $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'])) { +if (!empty($arrayfields['d.datec']['checked'])) +{ print '<td class="liste_titre">'; print '</td>'; } -// Birthday -if (!empty($arrayfields['d.birth']['checked'])) { +//Birthday +if (!empty($arrayfields['d.birth']['checked'])) +{ print '<td class="liste_titre">'; print '</td>'; } // Date modification -if (!empty($arrayfields['d.tms']['checked'])) { +if (!empty($arrayfields['d.tms']['checked'])) +{ print '<td class="liste_titre">'; print '</td>'; } // Status -if (!empty($arrayfields['d.statut']['checked'])) { +if (!empty($arrayfields['d.statut']['checked'])) +{ print '<td class="liste_titre right maxwidthonsmartphone">'; $liststatus = array( '-1'=>$langs->trans("Draft"), '1'=>$langs->trans("Validated"), '0'=>$langs->trans("Resiliated") ); - print $form->selectarray('search_status', $liststatus, $search_status, -2); + print $form->selectarray('statut', $liststatus, $statut, -2); print '</td>'; } // Action column @@ -637,7 +676,8 @@ $i = 0; $totalarray = array(); -while ($i < min($num, $limit)) { +while ($i < min($num, $limit)) +{ $obj = $db->fetch_object($resql); $datefin = $db->jdate($obj->datefin); @@ -651,7 +691,6 @@ $memberstatic->datefin = $datefin; $memberstatic->socid = $obj->fk_soc; $memberstatic->photo = $obj->photo; - $memberstatic->email = $obj->email; $memberstatic->morphy = $obj->morphy; $memberstatic->note_public = $obj->note_public; $memberstatic->note_private = $obj->note_private; @@ -666,73 +705,74 @@ print '<tr class="oddeven">'; - if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + { print '<td class="center">'.$obj->rowid.'</td>'; if (!$i) $totalarray['nbfield']++; } // Ref - if (!empty($arrayfields['d.ref']['checked'])) { + if (!empty($arrayfields['d.ref']['checked'])) + { print "<td>"; print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1); print "</td>\n"; if (!$i) $totalarray['nbfield']++; } // Civility - if (!empty($arrayfields['d.civility']['checked'])) { + if (!empty($arrayfields['d.civility']['checked'])) + { print "<td>"; print $obj->civility; print "</td>\n"; if (!$i) $totalarray['nbfield']++; } // Firstname - if (!empty($arrayfields['d.firstname']['checked'])) { + if (!empty($arrayfields['d.firstname']['checked'])) + { print "<td>"; print $obj->firstname; print "</td>\n"; if (!$i) $totalarray['nbfield']++; } // Lastname - if (!empty($arrayfields['d.lastname']['checked'])) { + if (!empty($arrayfields['d.lastname']['checked'])) + { print "<td>"; print $obj->lastname; print "</td>\n"; if (!$i) $totalarray['nbfield']++; } // Gender - if (!empty($arrayfields['d.gender']['checked'])) { + if (!empty($arrayfields['d.gender']['checked'])) + { print '<td>'; if ($obj->gender) print $langs->trans("Gender".$obj->gender); print '</td>'; if (!$i) $totalarray['nbfield']++; } // Company - if (!empty($arrayfields['d.company']['checked'])) { + if (!empty($arrayfields['d.company']['checked'])) + { print "<td>"; print $companyname; print "</td>\n"; } // Login - if (!empty($arrayfields['d.login']['checked'])) { + if (!empty($arrayfields['d.login']['checked'])) + { print "<td>".$obj->login."</td>\n"; if (!$i) $totalarray['nbfield']++; } - // Nature (Moral/Physical) - if (!empty($arrayfields['d.morphy']['checked'])) { - print '<td class="center">'; - $s = ''; - if ($obj->morphy == 'phy') { - $s .= '<span class="customer-back" title="'.$langs->trans("Physical").'">'.dol_substr($langs->trans("Physical"), 0, 1).'</span>'; - } - if ($obj->morphy == 'mor') { - $s .= '<span class="vendor-back" title="'.$langs->trans("Moral").'">'.dol_substr($langs->trans("Moral"), 0, 1).'</span>'; - } - print $s; - print "</td>\n"; + // Moral/Physique + if (!empty($arrayfields['d.morphy']['checked'])) + { + print "<td>".$memberstatic->getmorphylib($obj->morphy)."</td>\n"; if (!$i) $totalarray['nbfield']++; } // Type label - if (!empty($arrayfields['t.libelle']['checked'])) { + if (!empty($arrayfields['t.libelle']['checked'])) + { $membertypestatic->id = $obj->type_id; $membertypestatic->label = $obj->type; print '<td class="nowrap">'; @@ -741,33 +781,38 @@ if (!$i) $totalarray['nbfield']++; } // Address - if (!empty($arrayfields['d.address']['checked'])) { + if (!empty($arrayfields['d.address']['checked'])) + { print '<td class="nocellnopadd">'; print $obj->address; print '</td>'; if (!$i) $totalarray['nbfield']++; } // Zip - if (!empty($arrayfields['d.zip']['checked'])) { + if (!empty($arrayfields['d.zip']['checked'])) + { print '<td class="nocellnopadd">'; print $obj->zip; print '</td>'; if (!$i) $totalarray['nbfield']++; } // Town - if (!empty($arrayfields['d.town']['checked'])) { + if (!empty($arrayfields['d.town']['checked'])) + { print '<td class="nocellnopadd">'; print $obj->town; print '</td>'; if (!$i) $totalarray['nbfield']++; } // State - if (!empty($arrayfields['state.nom']['checked'])) { + if (!empty($arrayfields['state.nom']['checked'])) + { print "<td>".$obj->state_name."</td>\n"; if (!$i) $totalarray['nbfield']++; } // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { + if (!empty($arrayfields['country.code_iso']['checked'])) + { print '<td class="center">'; $tmparray = getCountry($obj->country, 'all'); print $tmparray['label']; @@ -775,34 +820,40 @@ if (!$i) $totalarray['nbfield']++; } // Phone pro - if (!empty($arrayfields['d.phone']['checked'])) { + if (!empty($arrayfields['d.phone']['checked'])) + { print '<td class="nocellnopadd">'; print $obj->phone; print '</td>'; if (!$i) $totalarray['nbfield']++; } // Phone perso - if (!empty($arrayfields['d.phone_perso']['checked'])) { + if (!empty($arrayfields['d.phone_perso']['checked'])) + { print '<td class="nocellnopadd">'; print $obj->phone_perso; print '</td>'; if (!$i) $totalarray['nbfield']++; } // Phone mobile - if (!empty($arrayfields['d.phone_mobile']['checked'])) { + if (!empty($arrayfields['d.phone_mobile']['checked'])) + { print '<td class="nocellnopadd">'; print $obj->phone_mobile; print '</td>'; if (!$i) $totalarray['nbfield']++; } // EMail - if (!empty($arrayfields['d.email']['checked'])) { + if (!empty($arrayfields['d.email']['checked'])) + { print "<td>".dol_print_email($obj->email, 0, 0, 1)."</td>\n"; } // End of subscription date $datefin = $db->jdate($obj->datefin); - if (!empty($arrayfields['d.datefin']['checked'])) { - if ($datefin) { + if (!empty($arrayfields['d.datefin']['checked'])) + { + if ($datefin) + { print '<td class="nowrap center">'; print dol_print_date($datefin, 'day'); if ($memberstatic->hasDelay()) { @@ -810,12 +861,17 @@ print " ".img_warning($langs->trans("SubscriptionLate").$textlate); } print '</td>'; - } else { + } + else + { print '<td class="nowrap left">'; - if ($obj->subscription == 'yes') { + if ($obj->subscription == 'yes') + { print $langs->trans("SubscriptionNotReceived"); if ($obj->statut > 0) print " ".img_warning(); - } else { + } + else + { print ' '; } print '</td>'; @@ -828,28 +884,32 @@ $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'])) { + if (!empty($arrayfields['d.datec']['checked'])) + { print '<td class="nowrap center">'; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print '</td>'; if (!$i) $totalarray['nbfield']++; } // Birth - if (!empty($arrayfields['d.birth']['checked'])) { + if (!empty($arrayfields['d.birth']['checked'])) + { print '<td class="nowrap center">'; print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser'); print '</td>'; if (!$i) $totalarray['nbfield']++; } // Date modification - if (!empty($arrayfields['d.tms']['checked'])) { + if (!empty($arrayfields['d.tms']['checked'])) + { print '<td class="nowrap center">'; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print '</td>'; if (!$i) $totalarray['nbfield']++; } // Status - if (!empty($arrayfields['d.statut']['checked'])) { + if (!empty($arrayfields['d.statut']['checked'])) + { print '<td class="nowrap right">'; print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5); print '</td>'; @@ -857,7 +917,8 @@ } // Action column print '<td class="center">'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + 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 '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; @@ -874,7 +935,8 @@ // If no record found -if ($num == 0) { +if ($num == 0) +{ $colspan = 1; foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; --- /tmp/dsg/dolibarr/htdocs/adherents/github_note.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_note.php @@ -31,7 +31,7 @@ // Load translation files required by the page $langs->loadLangs(array("companies", "members", "bills")); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $id = GETPOST('id', 'int'); // Security check @@ -39,9 +39,10 @@ $object = new Adherent($db); $result = $object->fetch($id); -if ($result > 0) { - $adht = new AdherentType($db); - $result = $adht->fetch($object->typeid); +if ($result > 0) +{ + $adht = new AdherentType($db); + $result = $adht->fetch($object->typeid); } $permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php @@ -63,10 +64,11 @@ $form = new Form($db); -if ($id) { +if ($id) +{ $head = member_prepare_head($object); - print dol_get_fiche_head($head, 'note', $langs->trans("Member"), -1, 'user'); + dol_fiche_head($head, 'note', $langs->trans("Member"), -1, 'user'); print "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">"; print '<input type="hidden" name="token" value="'.newToken().'">'; @@ -75,44 +77,45 @@ dol_banner_tab($object, 'id', $linkback); - print '<div class="fichecenter">'; + print '<div class="fichecenter">'; - print '<div class="underbanner clearboth"></div>'; + print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent tableforfield">'; - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.' </td></tr>'; - } + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.' </td></tr>'; + } - // Type - print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n"; + // Type + print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n"; - // Morphy - print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>'; - /*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">'; + // Morphy + print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>'; + /*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">'; print $form->showphoto('memberphoto',$member); print '</td>';*/ - print '</tr>'; + print '</tr>'; - // Company - print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>'; + // Company + print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>'; - // Civility - print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>'; - print '</tr>'; + // Civility + print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>'; + print '</tr>'; - print "</table>"; + print "</table>"; - print '</div>'; + print '</div>'; - $cssclass = 'titlefield'; - $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + $cssclass = 'titlefield'; + $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - print dol_get_fiche_end(); + dol_fiche_end(); } // End of page --- /tmp/dsg/dolibarr/htdocs/adherents/github_subscription.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_subscription.php @@ -40,15 +40,15 @@ $langs->loadLangs(array("companies", "bills", "members", "users", "mails", 'other')); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $rowid = GETPOST('rowid', 'int') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); $typeid = GETPOST('typeid', 'int'); // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; @@ -75,27 +75,30 @@ $defaultdelay = 1; $defaultdelayunit = 'y'; -if ($rowid) { - // Load member - $result = $object->fetch($rowid); - - // Define variables to know what current user can do on users - $canadduser = ($user->admin || $user->rights->user->user->creer); - // Define variables to know what current user can do on properties of user linked to edited member - if ($object->user_id) { - // $user is the user editing, $object->user_id is the user's id linked to the edited member - $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) - || (($user->id != $object->user_id) && $user->rights->user->user->creer)); - $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) - || (($user->id != $object->user_id) && $user->rights->user->user->password)); - } +if ($rowid) +{ + // Load member + $result = $object->fetch($rowid); + + // Define variables to know what current user can do on users + $canadduser = ($user->admin || $user->rights->user->user->creer); + // Define variables to know what current user can do on properties of user linked to edited member + if ($object->user_id) + { + // $user is the user editing, $object->user_id is the user's id linked to the edited member + $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) + || (($user->id != $object->user_id) && $user->rights->user->user->creer)); + $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) + || (($user->id != $object->user_id) && $user->rights->user->user->password)); + } } // Define variables to know what current user can do on members $canaddmember = $user->rights->adherent->creer; // Define variables to know what current user can do on properties of a member -if ($rowid) { - $caneditfieldmember = $user->rights->adherent->creer; +if ($rowid) +{ + $caneditfieldmember = $user->rights->adherent->creer; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -112,278 +115,315 @@ */ // Create third party from a member -if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { - if ($result > 0) { +if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) +{ + if ($result > 0) + { // Creation of thirdparty $company = new Societe($db); $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'), GETPOST('customercode', 'alpha')); - if ($result < 0) { + if ($result < 0) + { $langs->load("errors"); setEventMessages($company->error, $company->errors, 'errors'); - } else { + } + else + { $action = 'addsubscription'; } - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } -if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { - $error = 0; - if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only - if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) { - $error++; - setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); - } - } - - if (!$error) { - if ($_POST["userid"] != $object->user_id) { // If link differs from currently in database - $result = $object->setUserId($_POST["userid"]); - if ($result < 0) dol_print_error('', $object->error); - $_POST['action'] = ''; - $action = ''; - } - } +if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) +{ + $error = 0; + if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only + { + if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) + { + $error++; + setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); + } + } + + if (!$error) + { + if ($_POST["userid"] != $object->user_id) // If link differs from currently in database + { + $result = $object->setUserId($_POST["userid"]); + if ($result < 0) dol_print_error('', $object->error); + $_POST['action'] = ''; + $action = ''; + } + } } -if ($action == 'setsocid') { - $error = 0; - if (!$error) { - if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql .= " WHERE fk_soc = '".GETPOST('socid', 'int')."'"; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj && $obj->rowid > 0) { - $othermember = new Adherent($db); - $othermember->fetch($obj->rowid); - $thirdparty = new Societe($db); - $thirdparty->fetch(GETPOST('socid', 'int')); - $error++; - setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); - } - } - - if (!$error) { - $result = $object->setThirdPartyId(GETPOST('socid', 'int')); - if ($result < 0) dol_print_error('', $object->error); - $_POST['action'] = ''; - $action = ''; - } - } - } +if ($action == 'setsocid') +{ + $error = 0; + if (!$error) + { + if (GETPOST('socid', 'int') != $object->fk_soc) // If link differs from currently in database + { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; + $sql .= " WHERE fk_soc = '".GETPOST('socid', 'int')."'"; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj && $obj->rowid > 0) + { + $othermember = new Adherent($db); + $othermember->fetch($obj->rowid); + $thirdparty = new Societe($db); + $thirdparty->fetch(GETPOST('socid', 'int')); + $error++; + setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); + } + } + + if (!$error) + { + $result = $object->setThirdPartyId(GETPOST('socid', 'int')); + if ($result < 0) dol_print_error('', $object->error); + $_POST['action'] = ''; + $action = ''; + } + } + } } -if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !$_POST["cancel"]) { - $error = 0; - - $langs->load("banks"); - - $result = $object->fetch($rowid); - $result = $adht->fetch($object->typeid); - - // Subscription informations - $datesubscription = 0; - $datesubend = 0; - $paymentdate = 0; - if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"]) { - $datesubscription = dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - } - if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"]) { - $datesubend = dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); - } - if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"]) { - $paymentdate = dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); - } - $amount = price2num(GETPOST("subscription", 'alpha')); // Amount of subscription - $label = $_POST["label"]; - - // Payment informations - $accountid = $_POST["accountid"]; - $operation = $_POST["operation"]; // Payment mode - $num_chq = GETPOST("num_chq", "alphanohtml"); - $emetteur_nom = $_POST["chqemetteur"]; - $emetteur_banque = $_POST["chqbank"]; - $option = $_POST["paymentsave"]; - if (empty($option)) $option = 'none'; - $sendalsoemail = GETPOST("sendmail", 'alpha'); - - // Check parameters - if (!$datesubscription) { - $error++; - $langs->load("errors"); - $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription")); - setEventMessages($errmsg, null, 'errors'); - $action = 'addsubscription'; - } - if (GETPOST('end') && !$datesubend) { - $error++; - $langs->load("errors"); - $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription")); - setEventMessages($errmsg, null, 'errors'); - $action = 'addsubscription'; - } - if (!$datesubend) { - $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd'); - } - if (($option == 'bankviainvoice' || $option == 'bankdirect') && !$paymentdate) { - $error++; - $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); - setEventMessages($errmsg, null, 'errors'); - $action = 'addsubscription'; - } - - // Check if a payment is mandatory or not - if (!$error && $adht->subscription) { // Member type need subscriptions - if (!is_numeric($amount)) { - // If field is '' or not a numeric value - $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - setEventMessages($errmsg, null, 'errors'); - $error++; - $action = 'addsubscription'; - } else { - if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') { - if ($_POST["subscription"]) { - if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); - if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); - } else { - if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); - } - if ($errmsg) { - $error++; - setEventMessages($errmsg, null, 'errors'); - $error++; - $action = 'addsubscription'; - } - } - } - } - - // Record the subscription then complementary actions - if (!$error && $action == 'subscription') { - $db->begin(); - - // Create subscription - $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); - if ($crowid <= 0) { - $error++; - $errmsg = $object->error; - setEventMessages($object->error, $object->errors, 'errors'); - } - - if (!$error) { - $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque); - if ($result < 0) { +if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !$_POST["cancel"]) +{ + $error = 0; + + $langs->load("banks"); + + $result = $object->fetch($rowid); + $result = $adht->fetch($object->typeid); + + // Subscription informations + $datesubscription = 0; + $datesubend = 0; + $paymentdate = 0; + if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"]) + { + $datesubscription = dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + } + if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"]) + { + $datesubend = dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + } + if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"]) + { + $paymentdate = dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]); + } + $amount = price2num(GETPOST("subscription", 'alpha')); // Amount of subscription + $label = $_POST["label"]; + + // Payment informations + $accountid = $_POST["accountid"]; + $operation = $_POST["operation"]; // Payment mode + $num_chq = GETPOST("num_chq", "alphanohtml"); + $emetteur_nom = $_POST["chqemetteur"]; + $emetteur_banque = $_POST["chqbank"]; + $option = $_POST["paymentsave"]; + if (empty($option)) $option = 'none'; + $sendalsoemail = GETPOST("sendmail", 'alpha'); + + // Check parameters + if (!$datesubscription) + { + $error++; + $langs->load("errors"); + $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription")); + setEventMessages($errmsg, null, 'errors'); + $action = 'addsubscription'; + } + if (GETPOST('end') && !$datesubend) + { + $error++; + $langs->load("errors"); + $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription")); + setEventMessages($errmsg, null, 'errors'); + $action = 'addsubscription'; + } + if (!$datesubend) + { + $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd'); + } + if (($option == 'bankviainvoice' || $option == 'bankdirect') && !$paymentdate) + { + $error++; + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); + setEventMessages($errmsg, null, 'errors'); + $action = 'addsubscription'; + } + + // Check if a payment is mandatory or not + if (!$error && $adht->subscription) // Member type need subscriptions + { + if (!is_numeric($amount)) + { + // If field is '' or not a numeric value + $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + setEventMessages($errmsg, null, 'errors'); + $error++; + $action = 'addsubscription'; + } + else + { + if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') + { + if ($_POST["subscription"]) + { + if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); + } + else + { + if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); + } + if ($errmsg) + { + $error++; + setEventMessages($errmsg, null, 'errors'); + $error++; + $action = 'addsubscription'; + } + } + } + } + + // Record the subscription then complementary actions + if (!$error && $action == 'subscription') + { + $db->begin(); + + // Create subscription + $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); + if ($crowid <= 0) + { + $error++; + $errmsg = $object->error; + setEventMessages($object->error, $object->errors, 'errors'); + } + + if (!$error) + { + $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque); + if ($result < 0) + { $error++; setEventMessages($object->error, $object->errors, 'errors'); - } else { + } + else + { // If an invoice was created, it is into $object->invoice } - } - - if (!$error) { - $db->commit(); - } else { - $db->rollback(); - $action = 'addsubscription'; - } - - if (!$error) { - setEventMessages("SubscriptionRecorded", null, 'mesgs'); - } - - // Send email - if (!$error) { - // Send confirmation Email - if ($object->email && $sendalsoemail) { // $object is 'Adherent' - $parameters = array( - 'datesubscription' => $datesubscription, - 'amount' => $amount, - 'ccountid' => $accountid, - 'operation' => $operation, - 'label' => $label, - 'num_chq' => $num_chq, - 'emetteur_nom' => $emetteur_nom, - 'emetteur_banque' => $emetteur_banque, - 'datesubend' => $datesubend - ); - $reshook = $hookmanager->executeHooks('sendMail', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - if (empty($reshook)) { - $subject = ''; - $msg = ''; - - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } - - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); - - // Attach a file ? - $file = ''; - $listofpaths = array(); - $listofnames = array(); - $listofmimes = array(); - if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) { - $invoicediroutput = $conf->facture->dir_output; - $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; - - $listofpaths = array($file); - $listofnames = array(basename($file)); - $listofmimes = array(dol_mimetype($file)); - } - - $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; - - $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); - if ($result < 0) { - $errmsg = $object->error; - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); - } - } - } else { - setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); - } - } - - // Clean some POST vars - if (!$error) { - $_POST["subscription"] = ''; - $_POST["accountid"] = ''; - $_POST["operation"] = ''; - $_POST["label"] = ''; - $_POST["num_chq"] = ''; - } - } + } + + if (!$error) + { + $db->commit(); + } + else + { + $db->rollback(); + $action = 'addsubscription'; + } + + if (!$error) + { + setEventMessages("SubscriptionRecorded", null, 'mesgs'); + } + + // Send email + if (!$error) + { + // Send confirmation Email + if ($object->email && $sendalsoemail) // $object is 'Adherent' + { + $subject = ''; + $msg = ''; + + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; + + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + + // Attach a file ? + $file = ''; + $listofpaths = array(); + $listofnames = array(); + $listofmimes = array(); + if (is_object($object->invoice)) + { + $invoicediroutput = $conf->facture->dir_output; + $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; + + $listofpaths = array($file); + $listofnames = array(basename($file)); + $listofmimes = array(dol_mimetype($file)); + } + + $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; + + $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); + if ($result < 0) + { + $errmsg = $object->error; + setEventMessages($object->error, $object->errors, 'errors'); + } + else + { + setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); + } + } + else + { + setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); + } + } + + // Clean some POST vars + if (!$error) + { + $_POST["subscription"] = ''; + $_POST["accountid"] = ''; + $_POST["operation"] = ''; + $_POST["label"] = ''; + $_POST["num_chq"] = ''; + } + } } @@ -410,36 +450,38 @@ //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -if ($rowid > 0) { - $res = $object->fetch($rowid); - if ($res < 0) { dol_print_error($db, $object->error); exit; } - - $adht->fetch($object->typeid); - - $head = member_prepare_head($object); - - $rowspan = 10; - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; - if (!empty($conf->societe->enabled)) $rowspan++; - - print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; - print '<input type="hidden" name="token" value="'.newToken().'">'; - print '<input type="hidden" name="rowid" value="'.$object->id.'">'; - - print dol_get_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); - - $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; - - dol_banner_tab($object, 'rowid', $linkback); - - print '<div class="fichecenter">'; - print '<div class="fichehalfleft">'; - - print '<div class="underbanner clearboth"></div>'; - print '<table class="border centpercent tableforfield">'; +if ($rowid > 0) +{ + $res = $object->fetch($rowid); + if ($res < 0) { dol_print_error($db, $object->error); exit; } + + $adht->fetch($object->typeid); + + $head = member_prepare_head($object); + + $rowspan = 10; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; + if (!empty($conf->societe->enabled)) $rowspan++; + + print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; + print '<input type="hidden" name="rowid" value="'.$object->id.'">'; + + dol_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); + + $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; + + dol_banner_tab($object, 'rowid', $linkback); + + print '<div class="fichecenter">'; + print '<div class="fichehalfleft">'; + + print '<div class="underbanner clearboth"></div>'; + print '<table class="border centpercent tableforfield">'; // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.' </td></tr>'; } @@ -450,12 +492,6 @@ print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>'; print '</tr>'; - // Gender - print '<tr><td>'.$langs->trans("Gender").'</td>'; - print '<td>'; - if ($object->gender) print $langs->trans("Gender".$object->gender); - print '</td></tr>'; - // Company print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>'; @@ -464,71 +500,72 @@ print '</tr>'; // Password - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass); - if ($object->pass) { - print preg_replace('/./i', '*', $object->pass); - } else { - if ($user->admin) { - print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; - } else { - print $langs->trans("Hidden"); - } - } - if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) { - $langs->load("errors"); - $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); - print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); + if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) + { + $langs->load("errors"); + $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); + print ' '.$form->textwithpicto('', $htmltext, 1, 'warning'); } print '</td></tr>'; } - // Date end subscription - print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">'; - if ($object->datefin) { - print dol_print_date($object->datefin, 'day'); - if ($object->hasDelay()) { - print " ".img_warning($langs->trans("Late")); - } - } else { - if (!$adht->subscription) { - print $langs->trans("SubscriptionNotRecorded"); - if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled - } else { - print $langs->trans("SubscriptionNotReceived"); - if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled - } - } - print '</td></tr>'; - - print '</table>'; - - print '</div>'; - print '<div class="fichehalfright"><div class="ficheaddleft">'; - - print '<div class="underbanner clearboth"></div>'; - print '<table class="border tableforfield" width="100%">'; + print '</table>'; + + print '</div>'; + print '<div class="fichehalfright"><div class="ficheaddleft">'; + + print '<div class="underbanner clearboth"></div>'; + print '<table class="border tableforfield" width="100%">'; // Birthday - print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>'; + print '<tr><td class="titlefield">'.$langs->trans("Birthday").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>'; // Public print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>'; // Categories - if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) + { print '<tr><td>'.$langs->trans("Categories").'</td>'; print '<td colspan="2">'; print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1); print '</td></tr>'; } - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + // Date end subscription + print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">'; + if ($object->datefin) + { + print dol_print_date($object->datefin, 'day'); + if ($object->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } + } + else + { + if (!$adht->subscription) + { + print $langs->trans("SubscriptionNotRecorded"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } + else + { + print $langs->trans("SubscriptionNotReceived"); + if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } + } + print '</td></tr>'; // Third party Dolibarr - if (!empty($conf->societe->enabled)) { + if (!empty($conf->societe->enabled)) + { print '<tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans("LinkedToDolibarrThirdParty"); @@ -536,7 +573,8 @@ if ($action != 'editthirdparty' && $user->rights->adherent->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'), 1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="2" class="valeur">'; - if ($action == 'editthirdparty') { + if ($action == 'editthirdparty') + { $htmlname = 'socid'; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">'; print '<input type="hidden" name="rowid" value="'.$object->id.'">'; @@ -548,12 +586,17 @@ print '</td>'; print '<td class="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '</tr></table></form>'; - } else { - if ($object->fk_soc) { + } + else + { + if ($object->fk_soc) + { $company = new Societe($db); $result = $company->fetch($object->fk_soc); print $company->getNomUrl(1); - } else { + } + else + { print $langs->trans("NoThirdPartyAssociatedToMember"); } } @@ -565,199 +608,227 @@ print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans("LinkedToDolibarrUser"); print '</td>'; - if ($action != 'editlogin' && $user->rights->adherent->creer) { + if ($action != 'editlogin' && $user->rights->adherent->creer) + { print '<td class="right">'; - if ($user->rights->user->user->creer) { + if ($user->rights->user->user->creer) + { print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editlogin&rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToUser'), 1).'</a>'; } print '</td>'; } print '</tr></table>'; print '</td><td colspan="2" class="valeur">'; - if ($action == 'editlogin') { + if ($action == 'editlogin') + { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', ''); - } else { - if ($object->user_id) { + } + else + { + if ($object->user_id) + { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none'); - } else print $langs->trans("NoDolibarrAccess"); + } + else print $langs->trans("NoDolibarrAccess"); } print '</td></tr>'; - print "</table>\n"; + print "</table>\n"; print "</div></div></div>\n"; - print '<div style="clear:both"></div>'; - - print dol_get_fiche_end(); - - print '</form>'; - - - /* + print '<div style="clear:both"></div>'; + + dol_fiche_end(); + + print '</form>'; + + + /* * Action buttons */ - // Button to create a new subscription if member no draft neither resiliated - if ($user->rights->adherent->cotisation->creer) { - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - print '<div class="tabsAction">'; - - if ($object->statut > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription">'.$langs->trans("AddSubscription")."</a></div>"; - else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>'; - - print '</div>'; - } - } - - /* + // Button to create a new subscription if member no draft neither resiliated + if ($user->rights->adherent->cotisation->creer) + { + if ($action != 'addsubscription' && $action != 'create_thirdparty') + { + print '<div class="tabsAction">'; + + if ($object->statut > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription">'.$langs->trans("AddSubscription")."</a></div>"; + else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>'; + + print '</div>'; + } + } + + /* * List of subscriptions */ - if ($action != 'addsubscription' && $action != 'create_thirdparty') { - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; - $sql .= " c.rowid as crowid, c.subscription,"; - $sql .= " c.datec, c.fk_type as cfk_type,"; - $sql .= " c.dateadh as dateh,"; - $sql .= " c.datef,"; - $sql .= " c.fk_bank,"; - $sql .= " b.rowid as bid,"; - $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; - $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 .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; + if ($action != 'addsubscription' && $action != 'create_thirdparty') + { + $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; + $sql .= " c.rowid as crowid, c.subscription,"; + $sql .= " c.datec, c.fk_type as cfk_type,"; + $sql .= " c.dateadh as dateh,"; + $sql .= " c.datef,"; + $sql .= " c.fk_bank,"; + $sql .= " b.rowid as bid,"; + $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; + $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 .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; $sql .= $db->order($sortfield, $sortorder); - $result = $db->query($sql); - if ($result) { - $subscriptionstatic = new Subscription($db); - - $num = $db->num_rows($result); - - print '<table class="noborder centpercent">'."\n"; - - print '<tr class="liste_titre">'; - print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (!empty($conf->banque->enabled)) { - print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - } - print "</tr>\n"; - - $accountstatic = new Account($db); - $adh = new Adherent($db); - $adht = new AdherentType($db); - - $i = 0; - while ($i < $num) { - $objp = $db->fetch_object($result); - - $adh->id = $objp->rowid; - $adh->typeid = $objp->type; - - $subscriptionstatic->ref = $objp->crowid; - $subscriptionstatic->id = $objp->crowid; - - $typeid = $objp->cfk_type; - if ($typeid > 0) { - $adht->fetch($typeid); - } - - print '<tr class="oddeven">'; - print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>'; - print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'dayhour')."</td>\n"; - print '<td class="center">'; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print '</td>'; - print '<td class="center">'.dol_print_date($db->jdate($objp->dateh), 'day')."</td>\n"; - print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day')."</td>\n"; - print '<td class="right">'.price($objp->subscription).'</td>'; - if (!empty($conf->banque->enabled)) { + $result = $db->query($sql); + if ($result) + { + $subscriptionstatic = new Subscription($db); + + $num = $db->num_rows($result); + + print '<table class="noborder centpercent">'."\n"; + + print '<tr class="liste_titre">'; + print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($conf->banque->enabled)) + { + print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + } + print "</tr>\n"; + + $accountstatic = new Account($db); + $adh = new Adherent($db); + $adht = new AdherentType($db); + + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); + + $adh->id = $objp->rowid; + $adh->typeid = $objp->type; + + $subscriptionstatic->ref = $objp->crowid; + $subscriptionstatic->id = $objp->crowid; + + $typeid = ($objp->cfk_type > 0 ? $objp->cfk_type : $adh->typeid); + if ($typeid > 0) + { + $adht->fetch($typeid); + } + + print '<tr class="oddeven">'; + print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>'; + print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'dayhour')."</td>\n"; + print '<td class="center">'; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print '</td>'; + print '<td class="center">'.dol_print_date($db->jdate($objp->dateh), 'day')."</td>\n"; + print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day')."</td>\n"; + print '<td class="right">'.price($objp->subscription).'</td>'; + if (!empty($conf->banque->enabled)) + { print '<td class="right">'; - if ($objp->bid) { + if ($objp->bid) + { $accountstatic->label = $objp->label; $accountstatic->id = $objp->baid; $accountstatic->number = $objp->number; $accountstatic->account_number = $objp->account_number; $accountstatic->currency_code = $objp->currency_code; - if (!empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0) { + if (!empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0) + { $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($objp->fk_accountancy_journal); $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } - $accountstatic->ref = $objp->ref; - print $accountstatic->getNomUrl(1); - } else { - print ' '; - } - print '</td>'; - } - print "</tr>"; - $i++; - } - - if (empty($num)) { - $colspan = 6; - if (!empty($conf->banque->enabled)) $colspan++; - print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>'; - } - - print "</table>"; - } else { - dol_print_error($db); - } - } - - - if (($action != 'addsubscription' && $action != 'create_thirdparty')) { - // Shon online payment link - $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); - - if ($useonlinepayment) { - print '<br>'; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - print showOnlinePaymentUrl('membersubscription', $object->ref); - print '<br>'; - } - } - - /* + $accountstatic->ref = $objp->ref; + print $accountstatic->getNomUrl(1); + } + else + { + print ' '; + } + print '</td>'; + } + print "</tr>"; + $i++; + } + + if (empty($num)) { + $colspan = 6; + if (!empty($conf->banque->enabled)) $colspan++; + print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>'; + } + + print "</table>"; + } + else + { + dol_print_error($db); + } + } + + + if (($action != 'addsubscription' && $action != 'create_thirdparty')) + { + // Shon online payment link + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + + if ($useonlinepayment) + { + print '<br>'; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + print showOnlinePaymentUrl('membersubscription', $object->ref); + print '<br>'; + } + } + + /* * Add new subscription form */ - if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { - print '<br>'; - - print load_fiche_titre($langs->trans("NewCotisation")); - - // Define default choice for complementary actions - $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice - $invoiceonly = 0; // 1 means option by default is invoice only - $bankviainvoice = 0; // 1 means option by default is write to bank via invoice - if (GETPOST('paymentsave')) { - if (GETPOST('paymentsave') == 'bankdirect') $bankdirect = 1; - if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly = 1; - if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice = 1; - } else { - if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $bankviainvoice = 1; - elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) $bankdirect = 1; - elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $invoiceonly = 1; - } - - print "\n\n<!-- Form add subscription -->\n"; - - if ($conf->use_javascript_ajax) { - //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); - print "\n".'<script type="text/javascript" language="javascript">'; - print '$(document).ready(function () { + if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) + { + print '<br>'; + + print load_fiche_titre($langs->trans("NewCotisation")); + + // Define default choice for complementary actions + $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice + $invoiceonly = 0; // 1 means option by default is invoice only + $bankviainvoice = 0; // 1 means option by default is write to bank via invoice + if (GETPOST('paymentsave')) + { + if (GETPOST('paymentsave') == 'bankdirect') $bankdirect = 1; + if (GETPOST('paymentsave') == 'invoiceonly') $invoiceonly = 1; + if (GETPOST('paymentsave') == 'bankviainvoice') $bankviainvoice = 1; + } + else + { + if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $bankviainvoice = 1; + elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) $bankdirect = 1; + elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $invoiceonly = 1; + } + + print "\n\n<!-- Form add subscription -->\n"; + + if ($conf->use_javascript_ajax) + { + //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); + print "\n".'<script type="text/javascript" language="javascript">'; + print '$(document).ready(function () { $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ? 'show()' : 'hide()').'; $("#none, #invoiceonly").click(function() { $(".bankswitchclass").hide(); @@ -783,21 +854,25 @@ } }); '; - if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);'; - print '});'; - print '</script>'."\n"; - } + if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);'; + print '});'; + print '</script>'."\n"; + } // Confirm create third party - if ($action == 'create_thirdparty') { + if ($action == 'create_thirdparty') + { $companyalias = ''; $fullname = $object->getFullName($langs); - if ($object->morphy == 'mor') { + if ($object->morphy == 'mor') + { $companyname = $object->company; if (!empty($fullname)) $companyalias = $fullname; - } else { + } + else + { $companyname = $fullname; if (!empty($object->company)) $companyalias = $object->company; } @@ -808,19 +883,20 @@ array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') ); // If customer code was forced to "required", we ask it at creation to avoid error later - if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { + if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) + { $tmpcompany = new Societe($db); $tmpcompany->name = $companyname; - $tmpcompany->get_codeclient($tmpcompany, 0); + $tmpcompany->get_codeclient($tmpcompany, 0); $customercode = $tmpcompany->code_client; $formquestion[] = array( - 'label' => $langs->trans("CustomerCode"), - 'type' => 'text', - 'name' => 'customercode', - 'value' => $customercode, - 'morecss' => 'minwidth300', - 'moreattr' => 'maxlength="128"', - ); + 'label' => $langs->trans("CustomerCode"), + 'type' => 'text', + 'name' => 'customercode', + 'value' => $customercode, + 'morecss' => 'minwidth300', + 'moreattr' => 'maxlength="128"', + ); } // @todo Add other extrafields mandatory for thirdparty creation @@ -828,249 +904,265 @@ } - print '<form name="subscription" method="POST" action="'.$_SERVER["PHP_SELF"].'">'; - print '<input type="hidden" name="token" value="'.newToken().'">'; - print '<input type="hidden" name="action" value="subscription">'; - print '<input type="hidden" name="rowid" value="'.$rowid.'">'; - print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">'; - print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).'">'; - - print dol_get_fiche_head(''); + print '<form name="subscription" method="POST" action="'.$_SERVER["PHP_SELF"].'">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; + print '<input type="hidden" name="action" value="subscription">'; + print '<input type="hidden" name="rowid" value="'.$rowid.'">'; + print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">'; + print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($object->company).'">'; + + dol_fiche_head(''); print "<table class=\"border\" width=\"100%\">\n"; - print '<tbody>'; + print '<tbody>'; $today = dol_now(); - $datefrom = 0; - $dateto = 0; - $paymentdate = -1; - - // Date payment - if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { - $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); - } - - print '<tr>'; - // Date start subscription - print '<td class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>'; - if (GETPOST('reday')) { - $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - } - if (!$datefrom) { - $datefrom = $object->datevalid; - if ($object->datefin > 0) { - $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); - } - } - print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); - print "</td></tr>"; - - // Date end subscription - if (GETPOST('endday')) { - $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - } - if (!$dateto) { - $dateto = -1; // By default, no date is suggested - } - print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td>'; - print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); - print "</td></tr>"; - - if ($adht->subscription) { - // Amount - print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="subscription" size="6" value="'.GETPOST('subscription').'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>'; - - // Label - print '<tr><td>'.$langs->trans("Label").'</td>'; - print '<td><input name="label" type="text" size="32" value="'; - if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) print $langs->trans("Subscription").' '.dol_print_date(($datefrom ? $datefrom : time()), "%Y"); - print '"></td></tr>'; - - // Complementary action - if ((!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) { - $company = new Societe($db); - if ($object->fk_soc) { - $result = $company->fetch($object->fk_soc); - } - - // Title payments - //print '<tr><td colspan="2"><b>'.$langs->trans("Payment").'</b></td></tr>'; - - // No more action - print '<tr><td class="tdtop fieldrequired">'.$langs->trans('MoreActions'); - print '</td>'; - print '<td>'; - print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ? ' checked' : '').'> '.$langs->trans("None").'<br>'; - // Add entry into bank accoun - if (!empty($conf->banque->enabled)) { - print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ? ' checked' : ''); - print '> '.$langs->trans("MoreActionBankDirect").'<br>'; - } - // Add invoice with no payments - if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { - print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ? ' checked' : ''); - //if (empty($object->fk_soc)) print ' disabled'; - print '> '.$langs->trans("MoreActionInvoiceOnly"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { - print ' ('; - if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); - print $langs->trans("NoThirdPartyAssociatedToMember"); - print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">'; - print $langs->trans("CreateDolibarrThirdParty"); - print '</a>)'; - } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>'; - if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { + $datefrom = 0; + $dateto = 0; + $paymentdate = -1; + + // Date payment + if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) + { + $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); + } + + print '<tr>'; + // Date start subscription + print '<td class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>'; + if (GETPOST('reday')) + { + $datefrom = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + } + if (!$datefrom) + { + $datefrom = $object->datevalid; + if ($object->datefin > 0) + { + $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + } + } + print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); + print "</td></tr>"; + + // Date end subscription + if (GETPOST('endday')) + { + $dateto = dol_mktime(0, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + } + if (!$dateto) + { + $dateto = -1; // By default, no date is suggested + } + print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td>'; + print $form->selectDate($dateto, 'end', '', '', '', "subscription", 1, 0); + print "</td></tr>"; + + if ($adht->subscription) + { + // Amount + print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="subscription" size="6" value="'.GETPOST('subscription').'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>'; + + // Label + print '<tr><td>'.$langs->trans("Label").'</td>'; + print '<td><input name="label" type="text" size="32" value="'; + if (empty($conf->global->MEMBER_NO_DEFAULT_LABEL)) print $langs->trans("Subscription").' '.dol_print_date(($datefrom ? $datefrom : time()), "%Y"); + print '"></td></tr>'; + + // Complementary action + if (!empty($conf->banque->enabled) || !empty($conf->facture->enabled)) + { + $company = new Societe($db); + if ($object->fk_soc) + { + $result = $company->fetch($object->fk_soc); + } + + // Title payments + //print '<tr><td colspan="2"><b>'.$langs->trans("Payment").'</b></td></tr>'; + + // No more action + print '<tr><td class="tdtop fieldrequired">'.$langs->trans('MoreActions'); + print '</td>'; + print '<td>'; + print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ? ' checked' : '').'> '.$langs->trans("None").'<br>'; + // Add entry into bank accoun + if (!empty($conf->banque->enabled)) + { + print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.(!empty($bankdirect) ? ' checked' : ''); + print '> '.$langs->trans("MoreActionBankDirect").'<br>'; + } + // Add invoice with no payments + if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) + { + print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(!empty($invoiceonly) ? ' checked' : ''); + //if (empty($object->fk_soc)) print ' disabled'; + print '> '.$langs->trans("MoreActionInvoiceOnly"); + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + else + { + print ' ('; + if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); + print $langs->trans("NoThirdPartyAssociatedToMember"); + print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">'; + print $langs->trans("CreateDolibarrThirdParty"); + print '</a>)'; + } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>'; + if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) + { $prodtmp = new Product($db); - $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); - if ($result < 0) { - setEventMessage($prodtmp->error, 'errors'); - } + $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } - print '<br>'; - } - // Add invoice with payments - if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) { - print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ? ' checked' : ''); - //if (empty($object->fk_soc)) print ' disabled'; - print '> '.$langs->trans("MoreActionBankViaInvoice"); - if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; - else { - print ' ('; - if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); - print $langs->trans("NoThirdPartyAssociatedToMember"); - print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">'; - print $langs->trans("CreateDolibarrThirdParty"); - print '</a>)'; - } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>'; - if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { + print '<br>'; + } + // Add invoice with payments + if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) + { + print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ? ' checked' : ''); + //if (empty($object->fk_soc)) print ' disabled'; + print '> '.$langs->trans("MoreActionBankViaInvoice"); + if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; + else + { + print ' ('; + if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); + print $langs->trans("NoThirdPartyAssociatedToMember"); + print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">'; + print $langs->trans("CreateDolibarrThirdParty"); + print '</a>)'; + } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>'; + if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) + { $prodtmp = new Product($db); - $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); - if ($result < 0) { - setEventMessage($prodtmp->error, 'errors'); - } + $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } - print '<br>'; - } - print '</td></tr>'; - - // Bank account - print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>'; - $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); - print "</td></tr>\n"; - - // Payment mode - print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>'; - $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); - print "</td></tr>\n"; - - // Date of payment - print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>'; - print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); - print "</td></tr>\n"; - - print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero'); - print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; - print '</td>'; - print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!GETPOST('num_chq') ? '' : GETPOST('num_chq')).'"></td></tr>'; - - print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter'); - print ' <em>('.$langs->trans("ChequeMaker").')</em>'; - print '</td>'; - print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!GETPOST('chqemetteur') ? '' : GETPOST('chqemetteur')).'"></td></tr>'; - - print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank'); - print ' <em>('.$langs->trans("ChequeBank").')</em>'; - print '</td>'; - print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!GETPOST('chqbank') ? '' : GETPOST('chqbank')).'"></td></tr>'; - } - } - - print '<tr><td></td><td></td></tr>'; - - print '<tr><td>'.$langs->trans("SendAcknowledgementByMail").'</td>'; - print '<td>'; - if (!$object->email) { - print $langs->trans("NoEMail"); - } else { - $adht = new AdherentType($db); - $adht->fetch($object->typeid); - - // Send subscription email - $subject = ''; - $msg = ''; - - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } - - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); - - $tmp = '<input name="sendmail" type="checkbox"'.(GETPOST('sendmail', 'alpha') ? ' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; - $helpcontent = ''; - $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n"; - $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n"; - $helpcontent .= '<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n"; - if ($subjecttosend) { - $helpcontent .= $subjecttosend."\n"; - } else { - $langs->load("errors"); - $helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n"; - } - $helpcontent .= "<br>"; - $helpcontent .= '<b>'.$langs->trans("MailText").'</b>:<br>'; - if ($texttosend) { - $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; - } else { - $langs->load("errors"); - $helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n"; - } - print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); - } - print '</td></tr>'; - print '</tbody>'; - print '</table>'; - - print dol_get_fiche_end(); - - print '<div class="center">'; - print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">'; - print ' '; - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; - print '</div>'; - - print '</form>'; - - print "\n<!-- End form subscription -->\n\n"; - } - - //print '</td></tr>'; - //print '</table>'; -} else { - $langs->load("errors"); - print $langs->trans("ErrorRecordNotFound"); + print '<br>'; + } + print '</td></tr>'; + + // Bank account + print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>'; + $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 1); + print "</td></tr>\n"; + + // Payment mode + print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>'; + $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); + print "</td></tr>\n"; + + // Date of payment + print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>'; + print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); + print "</td></tr>\n"; + + print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero'); + print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; + print '</td>'; + print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!GETPOST('num_chq') ? '' : GETPOST('num_chq')).'"></td></tr>'; + + print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter'); + print ' <em>('.$langs->trans("ChequeMaker").')</em>'; + print '</td>'; + print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!GETPOST('chqemetteur') ? '' : GETPOST('chqemetteur')).'"></td></tr>'; + + print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank'); + print ' <em>('.$langs->trans("ChequeBank").')</em>'; + print '</td>'; + print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!GETPOST('chqbank') ? '' : GETPOST('chqbank')).'"></td></tr>'; + } + } + + print '<tr><td></td><td></td></tr>'; + + print '<tr><td>'.$langs->trans("SendAcknowledgementByMail").'</td>'; + print '<td>'; + if (!$object->email) + { + print $langs->trans("NoEMail"); + } + else + { + $adht = new AdherentType($db); + $adht->fetch($object->typeid); + + // Send subscription email + $subject = ''; + $msg = ''; + + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; + + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + + $tmp = '<input name="sendmail" type="checkbox"'.(GETPOST('sendmail', 'alpha') ? ' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; + $helpcontent = ''; + $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n"; + $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n"; + $helpcontent .= '<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n"; + if ($subjecttosend) { + $helpcontent .= $subjecttosend."\n"; + } else { + $langs->load("errors"); + $helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n"; + } + $helpcontent .= "<br>"; + $helpcontent .= '<b>'.$langs->trans("MailText").'</b>:<br>'; + if ($texttosend) { + $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; + } else { + $langs->load("errors"); + $helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n"; + } + print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); + } + print '</td></tr>'; + print '</tbody>'; + print '</table>'; + + dol_fiche_end(); + + print '<div class="center">'; + print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">'; + print ' '; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; + print '</div>'; + + print '</form>'; + + print "\n<!-- End form subscription -->\n\n"; + } + + //print '</td></tr>'; + //print '</table>'; +} +else +{ + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); } // End of page --- /tmp/dsg/dolibarr/htdocs/adherents/github_type.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_type.php @@ -38,7 +38,7 @@ $langs->load("members"); $rowid = GETPOST('rowid', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -61,13 +61,13 @@ $label = GETPOST("label", "alpha"); $morphy = GETPOST("morphy", "alpha"); -$status = GETPOST("status", "int"); +$statut = GETPOST("statut", "int"); $subscription = GETPOST("subscription", "int"); $duration_value = GETPOST('duration_value', 'int'); $duration_unit = GETPOST('duration_unit', 'alpha'); $vote = GETPOST("vote", "int"); -$comment = GETPOST("comment", 'restricthtml'); -$mail_valid = GETPOST("mail_valid", 'restricthtml'); +$comment = GETPOST("comment", 'none'); +$mail_valid = GETPOST("mail_valid", 'none'); // Security check $result = restrictedArea($user, 'adherent', $rowid, 'adherent_type'); @@ -79,12 +79,13 @@ // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -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_lastname = ""; - $search_login = ""; - $search_email = ""; - $type = ""; - $sall = ""; +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_lastname = ""; + $search_login = ""; + $search_email = ""; + $type = ""; + $sall = ""; } @@ -108,7 +109,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { $object->label = trim($label); $object->morphy = trim($morphy); - $object->status = (int) $status; + $object->statut = (int) $statut; $object->subscription = (int) $subscription; $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; @@ -123,7 +124,8 @@ if (empty($object->label)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); - } else { + } + else { $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'"; $result = $db->query($sql); if ($result) { @@ -136,28 +138,35 @@ } } - if (!$error) { + if (!$error) + { $id = $object->create($user); - if ($id > 0) { + if ($id > 0) + { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; } - } else { + } + else + { $action = 'create'; } } -if ($action == 'update' && $user->rights->adherent->configurer) { +if ($action == 'update' && $user->rights->adherent->configurer) +{ $object->fetch($rowid); $object->oldcopy = clone $object; $object->label = trim($label); $object->morphy = trim($morphy); - $object->status = (int) $status; + $object->statut = (int) $statut; $object->subscription = (int) $subscription; $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; @@ -171,9 +180,12 @@ $ret = $object->update($user); - if ($ret >= 0 && !count($object->errors)) { + if ($ret >= 0 && !count($object->errors)) + { setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs'); - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } @@ -181,15 +193,19 @@ exit; } -if ($action == 'confirm_delete' && $user->rights->adherent->configurer) { +if ($action == 'confirm_delete' && $user->rights->adherent->configurer) +{ $object->fetch($rowid); $res = $object->delete(); - if ($res > 0) { + if ($res > 0) + { setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; - } else { + } + else + { setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors'); $action = ''; } @@ -205,16 +221,19 @@ llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); + // List of members type -if (!$rowid && $action != 'create' && $action != 'edit') { - //print dol_get_fiche_head(''); +if (!$rowid && $action != 'create' && $action != 'edit') +{ + //dol_fiche_head(''); $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut as status, d.morphy"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; $result = $db->query($sql); - if ($result) { + if ($result) + { $num = $db->num_rows($result); $nbtotalofrecords = $num; @@ -225,9 +244,10 @@ if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; $newcardbutton = ''; - if ($user->rights->adherent->configurer) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); - } + if ($user->rights->adherent->configurer) + { + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); + } print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; @@ -247,7 +267,7 @@ print '<tr class="liste_titre">'; print '<th>'.$langs->trans("Ref").'</th>'; print '<th>'.$langs->trans("Label").'</th>'; - print '<th class="center">'.$langs->trans("MembersNature").'</th>'; + print '<th class="center">'.$langs->trans("MemberNature").'</th>'; print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>'; print '<th class="center">'.$langs->trans("VoteAllowed").'</th>'; print '<th class="center">'.$langs->trans("Status").'</th>'; @@ -263,7 +283,6 @@ $membertype->ref = $objp->rowid; $membertype->label = $objp->rowid; $membertype->status = $objp->status; - $membertype->subscription = $objp->subscription; print '<tr class="oddeven">'; print '<td>'; @@ -271,17 +290,18 @@ //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a> print '</td>'; print '<td>'.dol_escape_htmltag($objp->label).'</td>'; - print '<td class="center">'; - if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorAndPhy"); - print '</td>'; + print '<td class="center">'; + if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } + elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } + else print $langs->trans("MorPhy"); + print '</td>'; print '<td class="center">'.yn($objp->subscription).'</td>'; print '<td class="center">'.yn($objp->vote).'</td>'; print '<td class="center">'.$membertype->getLibStatut(5).'</td>'; if ($user->rights->adherent->configurer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>'; - else { + else print '<td class="right"> </td>'; - } print "</tr>"; $i++; } @@ -289,7 +309,9 @@ print '</div>'; print '</form>'; - } else { + } + else + { dol_print_error($db); } } @@ -300,7 +322,8 @@ /* Creation mode */ /* */ /* ************************************************************************** */ -if ($action == 'create') { +if ($action == 'create') +{ $object = new AdherentType($db); print load_fiche_titre($langs->trans("NewMemberType"), '', 'members'); @@ -309,7 +332,7 @@ print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="add">'; - print dol_get_fiche_head(''); + dol_fiche_head(''); print '<table class="border centpercent">'; print '<tbody>'; @@ -317,15 +340,15 @@ print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>'; print '<tr><td>'.$langs->trans("Status").'</td><td>'; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); + print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); print '</td></tr>'; - // Morphy + // Morphy $morphys = array(); - $morphys[""] = $langs->trans("MorAndPhy"); - $morphys["phy"] = $langs->trans("Physical"); + $morphys[""] = $langs->trans("MorPhy"); + $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); - print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>'; + print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>'; print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy'); print "</td></tr>"; @@ -344,12 +367,12 @@ print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('comment', $object->note, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); + $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor->Create(); print '</td></tr>'; @@ -359,12 +382,12 @@ print '<tbody>'; print "</table>\n"; - print dol_get_fiche_end(); + dol_fiche_end(); print '<div class="center">'; print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">'; print ' '; - print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />'; + print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />'; print '</div>'; print "</form>\n"; @@ -375,8 +398,10 @@ /* View mode */ /* */ /* ************************************************************************** */ -if ($rowid > 0) { - if ($action != 'edit') { +if ($rowid > 0) +{ + if ($action != 'edit') + { $object = new AdherentType($db); $object->fetch($rowid); $object->fetch_optionals(); @@ -384,13 +409,14 @@ /* * Confirmation deletion */ - if ($action == 'delete') { + if ($action == 'delete') + { print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$object->id, $langs->trans("DeleteAMemberType"), $langs->trans("ConfirmDeleteMemberType", $object->label), "confirm_delete", '', 0, 1); } $head = member_type_prepare_head($object); - print dol_get_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group'); + dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group'); $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; @@ -402,7 +428,7 @@ print '<table class="border centpercent">'; // Morphy - print '<tr><td>'.$langs->trans("MembersNature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>'; + print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>'; print '</tr>'; print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>'; @@ -414,9 +440,12 @@ print '</tr>'; print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.' '; - if ($object->duration_value > 1) { + if ($object->duration_value > 1) + { $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); - } elseif ($object->duration_value > 0) { + } + elseif ($object->duration_value > 0) + { $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; @@ -434,7 +463,7 @@ print '</table>'; print '</div>'; - print dol_get_fiche_end(); + dol_fiche_end(); /* * Buttons @@ -443,20 +472,23 @@ print '<div class="tabsAction">'; // Edit - if ($user->rights->adherent->configurer) { + if ($user->rights->adherent->configurer) + { print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>'; } // Add - if ($user->rights->adherent->configurer && !empty($object->status)) { - print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>'; - } else { - print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>'; - } + if ($user->rights->adherent->configurer && !empty($object->statut)) + { + print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>'; + } else { + print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>'; + } // Delete - if ($user->rights->adherent->configurer) { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>'; + if ($user->rights->adherent->configurer) + { + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>'; } print "</div>"; @@ -470,110 +502,120 @@ $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe as company,"; $sql .= " d.datefin,"; - $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut as status,"; + $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; $sql .= " t.libelle as type, t.subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE d.fk_adherent_type = t.rowid "; $sql .= " AND d.entity IN (".getEntity('adherent').")"; $sql .= " AND t.rowid = ".$object->id; - if ($sall) { + if ($sall) + { $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); } - if ($status != '') { - $sql .= natural_search('d.statut', $status, 2); - } - if ($action == 'search') { - if (GETPOST('search', 'alpha')) { + if ($status != '') + { + $sql .= natural_search('d.statut', $status, 2); + } + if ($action == 'search') + { + if (GETPOST('search', 'alpha')) + { $sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha')); } } - if (!empty($search_lastname)) { + if (!empty($search_lastname)) + { $sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname); } - if (!empty($search_login)) { + if (!empty($search_login)) + { $sql .= natural_search("d.login", $search_login); } - if (!empty($search_email)) { + if (!empty($search_email)) + { $sql .= natural_search("d.email", $search_email); } - if ($filter == 'uptodate') { - $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; - } - if ($filter == 'outofdate') { - $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; - } + if ($filter == 'uptodate') + { + $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)"; + } + if ($filter == 'outofdate') + { + $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; + } $sql .= " ".$db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { $resql = $db->query($sql); - if ($resql) $nbtotalofrecords = $db->num_rows($result); - 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; - } + if ($resql) $nbtotalofrecords = $db->num_rows($result); + 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; + } } $sql .= " ".$db->plimit($conf->liste_limit + 1, $offset); $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - $titre = $langs->trans("MembersList"); - if ($status != '') { - if ($status == '-1,1') { - $titre = $langs->trans("MembersListQualified"); - } elseif ($status == '-1') { - $titre = $langs->trans("MembersListToValid"); - } elseif ($status == '1' && !$filter) { - $titre = $langs->trans("MembersListValid"); - } elseif ($status == '1' && $filter == 'uptodate') { - $titre = $langs->trans("MembersListUpToDate"); - } elseif ($status == '1' && $filter == 'outofdate') { - $titre = $langs->trans("MembersListNotUpToDate"); - } elseif ($status == '0') { - $titre = $langs->trans("MembersListResiliated"); - } - } elseif ($action == 'search') { - $titre = $langs->trans("MembersListQualified"); - } - - if ($type > 0) { + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + $titre = $langs->trans("MembersList"); + if ($status != '') + { + if ($status == '-1,1') { $titre = $langs->trans("MembersListQualified"); } + elseif ($status == '-1') { $titre = $langs->trans("MembersListToValid"); } + elseif ($status == '1' && !$filter) { $titre = $langs->trans("MembersListValid"); } + elseif ($status == '1' && $filter == 'uptodate') { $titre = $langs->trans("MembersListUpToDate"); } + elseif ($status == '1' && $filter == 'outofdate') { $titre = $langs->trans("MembersListNotUpToDate"); } + elseif ($status == '0') { $titre = $langs->trans("MembersListResiliated"); } + } + elseif ($action == 'search') + { + $titre = $langs->trans("MembersListQualified"); + } + + if ($type > 0) + { $membertype = new AdherentType($db); - $result = $membertype->fetch($type); + $result = $membertype->fetch($type); $titre .= " (".$membertype->label.")"; - } - - $param = "&rowid=".$object->id; - if (!empty($status)) $param .= "&status=".$status; - if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname; - if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname; - if (!empty($search_login)) $param .= "&search_login=".$search_login; - if (!empty($search_email)) $param .= "&search_email=".$search_email; - if (!empty($filter)) $param .= "&filter=".$filter; - - if ($sall) { - print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; - } + } + + $param = "&rowid=".$object->id; + if (!empty($status)) $param .= "&status=".$status; + if (!empty($search_lastname)) $param .= "&search_lastname=".$search_lastname; + if (!empty($search_firstname)) $param .= "&search_firstname=".$search_firstname; + if (!empty($search_login)) $param .= "&search_login=".$search_login; + if (!empty($search_email)) $param .= "&search_email=".$search_email; + if (!empty($filter)) $param .= "&filter=".$filter; + + if ($sall) + { + print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall; + } print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; - print '<input type="hidden" name="token" value="'.newToken().'">'; + print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>'; print '<br>'; - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); - - $moreforfilter = ''; - - print '<div class="div-table-responsive">'; - print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; - - // Fields title search + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); + + $moreforfilter = ''; + + print '<div class="div-table-responsive">'; + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; + + // Fields title search print '<tr class="liste_titre_filter">'; print '<td class="liste_titre left">'; @@ -591,107 +633,123 @@ print '<td class="liste_titre right" colspan="2">'; print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; - print ' '; - print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">'; + print ' '; + print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">'; print '</td>'; print "</tr>\n"; print '<tr class="liste_titre">'; - print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder); - print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); - print "</tr>\n"; - - while ($i < $num && $i < $conf->liste_limit) { - $objp = $db->fetch_object($resql); - - $datefin = $db->jdate($objp->datefin); - - $adh = new Adherent($db); - $adh->lastname = $objp->lastname; - $adh->firstname = $objp->firstname; - $adh->datefin = $datefin; - $adh->need_subscription = $objp->subscription; - $adh->statut = $objp->status; - - // Lastname - print '<tr class="oddeven">'; - if ($objp->company != '') { - print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->company, 12).'</a></td>'."\n"; - } else { - print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n"; - } - - // Login - print "<td>".$objp->login."</td>\n"; - - // Type - /*print '<td class="nowrap">'; + print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder); + print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder); + print "</tr>\n"; + + while ($i < $num && $i < $conf->liste_limit) + { + $objp = $db->fetch_object($resql); + + $datefin = $db->jdate($objp->datefin); + + $adh = new Adherent($db); + $adh->lastname = $objp->lastname; + $adh->firstname = $objp->firstname; + + // Lastname + print '<tr class="oddeven">'; + if ($objp->company != '') + { + print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n"; + } + else + { + print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n"; + } + + // Login + print "<td>".$objp->login."</td>\n"; + + // Type + /*print '<td class="nowrap">'; $membertypestatic->id=$objp->type_id; $membertypestatic->label=$objp->type; print $membertypestatic->getNomUrl(1,12); print '</td>'; */ - // Moral/Physique - print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n"; - - // EMail - print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n"; - - // Status - print '<td class="nowrap">'; - print $adh->getLibStatut(2); + // Moral/Physique + print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n"; + + // EMail + print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n"; + + // Statut + print '<td class="nowrap">'; + print $adh->LibStatut($objp->statut, $objp->subscription, $datefin, 2); + print "</td>"; + + // Date end subscription + if ($datefin) + { + print '<td class="nowrap center">'; + if ($datefin < dol_now() && $objp->statut > 0) + { + print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate")); + } + else + { + print dol_print_date($datefin, 'day'); + } + print '</td>'; + } + else + { + print '<td class="nowrap left">'; + if ($objp->subscription == 'yes') + { + print $langs->trans("SubscriptionNotReceived"); + if ($objp->statut > 0) print " ".img_warning(); + } + else + { + print ' '; + } + print '</td>'; + } + + // Actions + print '<td class="center">'; + if ($user->rights->adherent->creer) + { + print '<a class="editfielda" href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>'; + } + print ' '; + if ($user->rights->adherent->supprimer) + { + print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>'; + } print "</td>"; - // Date end subscription - if ($datefin) { - print '<td class="nowrap center">'; - if ($datefin < dol_now() && $objp->status > 0) { - print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate")); - } else { - print dol_print_date($datefin, 'day'); - } - print '</td>'; - } else { - print '<td class="nowrap left">'; - if ($objp->subscription == 'yes') { - print $langs->trans("SubscriptionNotReceived"); - if ($objp->status > 0) print " ".img_warning(); - } else { - print ' '; - } - print '</td>'; - } - - // Actions - print '<td class="center">'; - if ($user->rights->adherent->creer) { - print '<a class="editfielda marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>'; - } - if ($user->rights->adherent->supprimer) { - print '<a class="marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>'; - } - print "</td>"; - - print "</tr>\n"; - $i++; + print "</tr>\n"; + $i++; + } + + print "</table>\n"; + print '</div>'; + print '</form>'; + + if ($num > $conf->liste_limit) + { + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); } - - print "</table>\n"; - print '</div>'; - print '</form>'; - - if ($num > $conf->liste_limit) { - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); - } - } else { - dol_print_error($db); + } + else + { + dol_print_error($db); } } @@ -701,7 +759,8 @@ /* */ /* ************************************************************************** */ - if ($action == 'edit') { + if ($action == 'edit') + { $object = new AdherentType($db); $object->fetch($rowid); $object->fetch_optionals(); @@ -713,27 +772,27 @@ print '<input type="hidden" name="rowid" value="'.$object->id.'">'; print '<input type="hidden" name="action" value="update">'; - print dol_get_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); + dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group'); print '<table class="border centpercent">'; print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>'; - print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth300" name="label" value="'.dol_escape_htmltag($object->label).'"></td></tr>'; + print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>'; print '<tr><td>'.$langs->trans("Status").'</td><td>'; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); - print '</td></tr>'; - - // Morphy - $morphys[""] = $langs->trans("MorAndPhy"); - $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Moral"); - print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>'; - print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : $object->morphy); - print "</td></tr>"; - - print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>'; + print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->statut); + print '</td></tr>'; + + // Morphy + $morphys[""] = $langs->trans("MorPhy"); + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Moral"); + print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>'; + print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy); + print "</td></tr>"; + + print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>'; print $form->selectyesno("subscription", $object->subscription, 1); print '</td></tr>'; @@ -743,7 +802,7 @@ print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3">'; print '<input name="duration_value" size="5" value="'.$object->duration_value.'"> '; - print $formproduct->selectMeasuringUnits("duration_unit", "time", ($object->duration_unit === '' ? 'y' : $object->duration_unit), 0, 1); + print $formproduct->selectMeasuringUnits("duration_unit", "time", $object->duration_unit, 0, 1); print '</td></tr>'; print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; @@ -762,12 +821,12 @@ print '</table>'; - print dol_get_fiche_end(); + dol_fiche_end(); print '<div class="center">'; - print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">'; + print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; print ' '; - print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans("Cancel").'">'; + print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">'; print '</div>'; print "</form>"; --- /tmp/dsg/dolibarr/htdocs/adherents/github_type_ldap.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_type_ldap.php @@ -33,7 +33,7 @@ $langs->loadLangs(array("admin", "members", "ldap")); $id = GETPOST('rowid', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); // Security check $result = restrictedArea($user, 'adherent', $id, 'adherent_type'); @@ -53,12 +53,15 @@ $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'); -if (empty($reshook)) { - if ($action == 'dolibarr2ldap') { +if (empty($reshook)) +{ + if ($action == 'dolibarr2ldap') + { $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) { + if ($result > 0) + { $object->listMembersForMemberType('', 1); $info = $object->_load_ldap_info(); @@ -70,7 +73,8 @@ if ($result >= 0) { setEventMessages($langs->trans("MemberTypeSynchronized"), null, 'mesgs'); - } else { + } + else { setEventMessages($ldap->error, $ldap->errors, 'errors'); } } @@ -86,7 +90,7 @@ $head = member_type_prepare_head($object); -print dol_get_fiche_head($head, 'ldap', $langs->trans("MemberType"), -1, 'group'); +dol_fiche_head($head, 'ldap', $langs->trans("MemberType"), -1, 'group'); $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; @@ -114,7 +118,7 @@ print '</div>'; -print dol_get_fiche_end(); +dol_fiche_end(); /* * Action bar @@ -122,8 +126,9 @@ print '<div class="tabsAction">'; -if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) { - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>'; +if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) +{ + print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>'; } print "</div>\n"; @@ -145,29 +150,38 @@ // LDAP reading $ldap = new Ldap(); $result = $ldap->connect_bind(); -if ($result > 0) { - $info = $object->_load_ldap_info(); - $dn = $object->_load_ldap_dn($info, 1); - $search = "(".$object->_load_ldap_dn($info, 2).")"; +if ($result > 0) +{ + $info = $object->_load_ldap_info(); + $dn = $object->_load_ldap_dn($info, 1); + $search = "(".$object->_load_ldap_dn($info, 2).")"; - $records = $ldap->getAttribute($dn, $search); + $records = $ldap->getAttribute($dn, $search); - //print_r($records); + //print_r($records); - // Show tree - if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { - if (!is_array($records)) { - print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; - } else { - $result = show_ldap_content($records, 0, $records['count'], true); - } - } else { - print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>'; - } + // Show tree + if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) + { + if (!is_array($records)) + { + print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; + } + else + { + $result = show_ldap_content($records, 0, $records['count'], true); + } + } + else + { + print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>'; + } - $ldap->unbind(); - $ldap->close(); -} else { + $ldap->unbind(); + $ldap->close(); +} +else +{ setEventMessages($ldap->error, $ldap->errors, 'errors'); } --- /tmp/dsg/dolibarr/htdocs/adherents/github_type_translation.php +++ /tmp/dsg/dolibarr/htdocs/adherents/client_type_translation.php @@ -35,9 +35,8 @@ $langs->loadLangs(array('members', 'languages')); $id = GETPOST('rowid', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); -$ref = GETPOST('ref', 'alphanohtml'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); @@ -52,80 +51,99 @@ */ // return to translation display if cancellation -if ($cancel == $langs->trans("Cancel")) { +if ($cancel == $langs->trans("Cancel")) +{ $action = ''; } -if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) { +if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) +{ $object = new AdherentType($db); $object->fetch($id); $object->delMultiLangs(GETPOST('langtodelete', 'alpha'), $user); } // Add translation -if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) { +if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) +{ $object = new AdherentType($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); - $forcelangprod = GETPOST("forcelangprod", 'aZ09'); - // update of object - if ($forcelangprod == $current_lang) { - $object->label = GETPOST("libelle", 'alphanohtml'); - $object->description = dol_htmlcleanlastbr(GETPOST("desc", 'restricthtml')); - $object->other = dol_htmlcleanlastbr(GETPOST("other", 'restricthtml')); - } else { - $object->multilangs[$forcelangprod]["label"] = GETPOST("libelle", 'alphanohtml'); - $object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr(GETPOST("desc", 'restricthtml')); - $object->multilangs[$forcelangprod]["other"] = dol_htmlcleanlastbr(GETPOST("other", 'restricthtml')); + if ($_POST["forcelangprod"] == $current_lang) + { + $object->label = $_POST["libelle"]; + $object->description = dol_htmlcleanlastbr($_POST["desc"]); + $object->other = dol_htmlcleanlastbr($_POST["other"]); + } + else + { + $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; + $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); + $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]); } // backup into database - if ($object->setMultiLangs($user) > 0) { + if ($object->setMultiLangs($user) > 0) + { $action = ''; - } else { + } + else + { $action = 'add'; setEventMessages($object->error, $object->errors, 'errors'); } } // Edit translation -if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) { +if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) +{ $object = new AdherentType($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); - foreach ($object->multilangs as $key => $value) { // saving new values in the object - if ($key == $current_lang) { - $object->label = GETPOST("libelle-".$key, 'alphanohtml'); - $object->description = dol_htmlcleanlastbr(GETPOST("desc-".$key, 'restricthtml')); - $object->other = dol_htmlcleanlastbr(GETPOST("other-".$key, 'restricthtml')); - } else { - $object->multilangs[$key]["label"] = GETPOST("libelle-".$key, 'alphanohtml'); - $object->multilangs[$key]["description"] = dol_htmlcleanlastbr(GETPOST("desc-".$key, 'restricthtml')); - $object->multilangs[$key]["other"] = dol_htmlcleanlastbr(GETPOST("other-".$key, 'restricthtml')); + foreach ($object->multilangs as $key => $value) // saving new values in the object + { + if ($key == $current_lang) + { + $object->label = $_POST["libelle-".$key]; + $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); } - } - - if ($object->setMultiLangs($user) > 0) { + else + { + $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); + } + } + + if ($object->setMultiLangs($user) > 0) + { $action = ''; - } else { + } + else + { $action = 'edit'; setEventMessages($object->error, $object->errors, 'errors'); } } // Delete translation -if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) { +if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) +{ $object = new AdherentType($db); $object->fetch($id); $langtodelete = GETPOST('langdel', 'alpha'); - if ($object->delMultiLangs($langtodelete, $user) > 0) { + if ($object->delMultiLangs($langtodelete, $user) > 0) + { $action = ''; - } else { + } + else + { $action = 'edit'; setEventMessages($object->error, $object->errors, 'errors'); } @@ -156,20 +174,22 @@ // Calculate $cnt_trans $cnt_trans = 0; -if (!empty($object->multilangs)) { - foreach ($object->multilangs as $key => $value) { - $cnt_trans++; - } -} - - -print dol_get_fiche_head($head, 'translation', $titre, 0, 'group'); +if (!empty($object->multilangs)) +{ + foreach ($object->multilangs as $key => $value) + { + $cnt_trans++; + } +} + + +dol_fiche_head($head, 'translation', $titre, 0, 'group'); $linkback = '<a href="'.dol_buildpath('/adherents/type.php', 1).'">'.$langs->trans("BackToList").'</a>'; dol_banner_tab($object, 'rowid', $linkback); -print dol_get_fiche_end(); +dol_fiche_end(); @@ -181,18 +201,21 @@ print "\n<div class=\"tabsAction\">\n"; -if ($action == '') { - if ($user->rights->produit->creer || $user->rights->service->creer) { - print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=add&rowid='.$object->id.'">'.$langs->trans("Add").'</a>'; - if ($cnt_trans > 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=edit&rowid='.$object->id.'">'.$langs->trans("Update").'</a>'; - } +if ($action == '') +{ + if ($user->rights->produit->creer || $user->rights->service->creer) + { + print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=add&rowid='.$object->id.'">'.$langs->trans("Add").'</a>'; + if ($cnt_trans > 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=edit&rowid='.$object->id.'">'.$langs->trans("Update").'</a>'; + } } print "\n</div>\n"; -if ($action == 'edit') { +if ($action == 'edit') +{ //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -201,14 +224,16 @@ print '<input type="hidden" name="action" value="vedit">'; print '<input type="hidden" name="rowid" value="'.$object->id.'">'; - if (!empty($object->multilangs)) { - foreach ($object->multilangs as $key => $value) { + if (!empty($object->multilangs)) + { + foreach ($object->multilangs as $key => $value) + { $s = picto_from_langcode($key); - print '<br>'.($s ? $s.' ' : '').' <b>'.$langs->trans('Language_'.$key).':</b> <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>"; + print "<br>".($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"')."</a><br>"; print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent">'; - print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" class="minwidth300" value="'.dol_escape_htmltag($object->multilangs[$key]["label"]).'"></td></tr>'; + print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.dol_escape_htmltag($object->multilangs[$key]["label"]).'"></td></tr>'; print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>'; $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); @@ -221,17 +246,21 @@ print '<br>'; print '<div class="center">'; - print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">'; + print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; print ' '; - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '</div>'; print '</form>'; -} elseif ($action != 'add') { - if (!empty($object->multilangs)) { - foreach ($object->multilangs as $key => $value) { +} +elseif ($action != 'add') +{ + if (!empty($object->multilangs)) + { + foreach ($object->multilangs as $key => $value) + { $s = picto_from_langcode($key); - print ($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&token='.newToken().'&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>'; + print ($s ? $s.' ' : '')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>'; print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; @@ -251,7 +280,8 @@ * Form to add a new translation */ -if ($action == 'add' && $user->rights->adherent->configurer) { +if ($action == 'add' && $user->rights->adherent->configurer) +{ //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -261,13 +291,13 @@ print '<input type="hidden" name="action" value="vadd">'; print '<input type="hidden" name="rowid" value="'.GETPOST("rowid", 'int').'">'; - print dol_get_fiche_head(); + dol_fiche_head(); print '<table class="border centpercent">'; print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans('Language').'</td><td>'; - print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); + print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); print '</td></tr>'; - print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" class="minwidth300" value="'.dol_escape_htmltag(GETPOST("libelle", 'alphanohtml')).'"></td></tr>'; + print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>'; print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>'; $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); @@ -275,12 +305,12 @@ print '</table>'; - print dol_get_fiche_end(); + dol_fiche_end(); print '<div class="center">'; - print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">'; + print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; print ' '; - print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '</div>'; print '</form>';