diff --git a/build/exe/doliwamp/config.inc.php.install b/build/exe/doliwamp/config.inc.php.install index 19a3d36a45e..6ad04752766 100644 --- a/build/exe/doliwamp/config.inc.php.install +++ b/build/exe/doliwamp/config.inc.php.install @@ -542,7 +542,7 @@ $cfg['ThemePerServer'] = FALSE; // allow diferent theme for each co * %f will be replaced by a list of field names. * (%t and %f only applies to DefaultQueryTable) */ -$cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1'; +$cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1 = 1'; $cfg['DefaultQueryDatabase'] = ''; /** diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 32476f137a8..fa2062be7c1 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -105,6 +105,7 @@ if ($action == 'set_default') { $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'ADHERENT_CREATE_EXTERNAL_USER_LOGIN', GETPOST('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 'alpha'), 'chaine', 0, '', $conf->entity); $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); // Use vat for invoice creation if ($conf->facture->enabled) { @@ -217,6 +218,11 @@ print ''.$langs->trans("MemberSendInformationByMailByDef print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1); print "\n"; +// Create an external user login for each new member subscription validated +print ''.$langs->trans("MemberCreateAnExternalUserForSubscriptionValidated").''; +print $form->selectyesno('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', (!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN) ? $conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN : 0), 1); +print "\n"; + // Insert subscription into bank account print ''.$langs->trans("MoreActionsOnSubscription").''; $arraychoices = array('0'=>$langs->trans("None")); diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 93a0761183b..1bf575aeb8a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -284,6 +284,7 @@ if (empty($reshook)) { $object->phone_perso = trim(GETPOST("phone_perso", 'alpha')); $object->phone_mobile = trim(GETPOST("phone_mobile", 'alpha')); $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); + $object->url = trim(GETPOST('member_url', 'custom', 0, FILTER_SANITIZE_URL)); $object->socialnetworks = array(); foreach ($socialnetworks as $key => $value) { if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { @@ -431,6 +432,7 @@ if (empty($reshook)) { // $facebook=GETPOST("member_facebook", 'alpha'); // $linkedin=GETPOST("member_linkedin", 'alpha'); $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); + $url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); $login = GETPOST("member_login", 'alphanohtml'); $pass = GETPOST("password", 'alpha'); $photo = GETPOST("photo", 'alpha'); @@ -469,6 +471,7 @@ if (empty($reshook)) { // $object->linkedin = $linkedin; $object->email = $email; + $object->url = $url; $object->login = $login; $object->pass = $pass; $object->birth = $birthdate; @@ -537,6 +540,10 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors'); } + if (!empty($object->url) && !isValidUrl($object->url)) { + $langs->load("errors"); + setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors'); + } $public = 0; if (isset($public)) { $public = 1; @@ -1028,6 +1035,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').''; print ''.img_picto('', 'object_email').' '; + // Website + print ''.$form->editfieldkey('Web', 'member_url', '', $object, 0).''; + print ''.img_picto('', 'globe').' '; + // Address print ''.$langs->trans("Address").''; print ''; @@ -1272,6 +1283,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').''; print ''.img_picto('', 'object_email').' email).'">'; + // Website + print ''.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).''; + print ''.img_picto('', 'globe').' '; + // Address print ''.$langs->trans("Address").''; print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 80d14ee9ceb..a663cea85d2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -140,6 +140,11 @@ class Adherent extends CommonObject */ public $email; + /** + * @var string url + */ + public $url; + /** * @var array array of socialnetworks */ @@ -307,6 +312,7 @@ class Adherent extends CommonObject 'state_id' => array('type' => 'integer', 'label' => 'State id', 'enabled' => 1, 'visible' => -1, 'position' => 90), 'country' => array('type' => 'integer:Ccountry:core/class/ccountry.class.php', 'label' => 'Country', 'enabled' => 1, 'visible' => -1, 'position' => 95), 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'visible' => -1, 'position' => 100), + 'url' =>array('type'=>'varchar(255)', 'label'=>'Url', 'enabled'=>1, 'visible'=>-1, 'position'=>110), 'socialnetworks' => array('type' => 'text', 'label' => 'Socialnetworks', 'enabled' => 1, 'visible' => -1, 'position' => 105), 'phone' => array('type' => 'varchar(30)', 'label' => 'Phone', 'enabled' => 1, 'visible' => -1, 'position' => 115), 'phone_perso' => array('type' => 'varchar(30)', 'label' => 'Phone perso', 'enabled' => 1, 'visible' => -1, 'position' => 120), @@ -661,6 +667,7 @@ class Adherent extends CommonObject $this->setUpperOrLowerCase(); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private); + $this->url = $this->url ?clean_url($this->url, 0) : ''; // Check parameters if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) { @@ -686,6 +693,7 @@ class Adherent extends CommonObject $sql .= ", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) : "null"); $sql .= ", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) : "null"); $sql .= ", email = '".$this->db->escape($this->email)."'"; + $sql .= ", url = ".(!empty($this->url) ? "'".$this->db->escape($this->url)."'" : "null"); $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", phone = ".($this->phone ? "'".$this->db->escape($this->phone)."'" : "null"); $sql .= ", phone_perso = ".($this->phone_perso ? "'".$this->db->escape($this->phone_perso)."'" : "null"); @@ -1298,7 +1306,7 @@ class Adherent extends CommonObject $sql = "SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,"; $sql .= " d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql .= " d.note_public,"; - $sql .= " d.email, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; + $sql .= " d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql .= " d.datec as datec,"; $sql .= " d.tms as datem,"; @@ -1377,6 +1385,7 @@ class Adherent extends CommonObject $this->phone_perso = $obj->phone_perso; $this->phone_mobile = $obj->phone_mobile; $this->email = $obj->email; + $this->url = $obj->url; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 775c0d25c81..1ec9d498b9d 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -247,6 +247,42 @@ if (empty($reshook)) { } } + // Create external user + if ($massaction == 'createexternaluser' && $user->rights->adherent->creer && $user->rights->user->user->creer) { + $tmpmember = new Adherent($db); + $error = 0; + $nbcreated = 0; + + $db->begin(); + + foreach ($toselect as $idtoclose) { + $tmpmember->fetch($idtoclose); + + if (!empty($tmpmember->fk_soc)) { + $nuser = new User($db); + $tmpuser = dol_clone($tmpmember); + + $result = $nuser->create_from_member($tmpuser, $tmpmember->login); + + if ($result < 0 && !count($tmpmember->errors)) { + setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); + } else { + if ($result > 0) { + $nbcreated++; + } + } + } + } + + if (!$error) { + setEventMessages($langs->trans("XExternalUserCreated", $nbcreated), null, 'mesgs'); + + $db->commit(); + } else { + $db->rollback(); + } + } + // Mass actions $objectclass = 'Adherent'; $objectlabel = 'Members'; @@ -555,6 +591,9 @@ if ($user->rights->adherent->supprimer) { if ($user->rights->societe->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } +if ($user->rights->adherent->creer && $user->rights->user->user->creer) { + $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser"); +} if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { $arrayofmassactions = array(); } diff --git a/htdocs/adherents/partnership.php b/htdocs/adherents/partnership.php new file mode 100644 index 00000000000..3cd70de3228 --- /dev/null +++ b/htdocs/adherents/partnership.php @@ -0,0 +1,558 @@ + + * Copyright (C) 2021 NextGestion + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file partnership_card.php + * \ingroup partnership + * \brief Page to create/edit/view partnership + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +dol_include_once('/partnership/class/partnership.class.php'); +dol_include_once('/partnership/lib/partnership.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("companies","members","partnership", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$memberid = GETPOST('rowid', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +$member = new Adherent($db); +if ($memberid > 0) { + $member->fetch($memberid); +} + +// Initialize technical objects +$object = new Partnership($db); +$extrafields = new ExtraFields($db); +$adht = new AdherentType($db); +$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('partnershipthirdparty', 'globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); + +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } +} + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +$permissiontoread = $user->rights->partnership->read; +$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php +$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; + + +if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'member') accessforbidden(); +if (empty($conf->partnership->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); +if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); + +$partnershipid = $object->fetch(0, "", $memberid); +if (empty($action) && empty($partnershipid)) { + $action = 'create'; +} +if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT) accessforbidden(); + +if (empty($memberid) && $object) { + $memberid = $object->fk_member; +} +/* + * Actions + */ + +$parameters = array(); +$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'); +} + +$date_start = dol_mktime(0, 0, 0, GETPOST('date_partnership_startmonth', 'int'), GETPOST('date_partnership_startday', 'int'), GETPOST('date_partnership_startyear', 'int')); +$date_end = dol_mktime(0, 0, 0, GETPOST('date_partnership_endmonth', 'int'), GETPOST('date_partnership_endday', 'int'), GETPOST('date_partnership_endyear', 'int')); + +if (empty($reshook)) { + $error = 0; + + $backtopage = dol_buildpath('/partnership/partnership.php', 1).'?rowid='.($memberid > 0 ? $memberid : '__ID__'); + + $triggermodname = 'PARTNERSHIP_MODIFY'; // Name of trigger action code to execute when we modify record + + if ($action == 'add' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $old_start_date = $object->date_partnership_start; + + $object->fk_member = $memberid; + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->date_creation = $now; + $object->fk_user_creat = $user->id; + $object->entity = $conf->entity; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->create($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'create'; + } else { + $db->commit(); + } + } elseif ($action == 'update' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $object->oldcopy = clone $object; + + $old_start_date = $object->date_partnership_start; + + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->fk_user_creat = $user->id; + $object->fk_user_modif = $user->id; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->update($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'edit'; + } else { + $db->commit(); + } + } elseif ($action == 'confirm_close' || $action == 'update_extras') { + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + header("Location: ".$_SERVER['PHP_SELF']."?rowid=".$memberid); + exit; + } + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; +} + +$object->fields['fk_member']['visible'] = 0; +if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) $object->fields['reason_decline_or_cancel']['visible'] = 1; +$object->fields['note_public']['visible'] = 1; + +/* + * View + * + * Put here all code to build page + */ + +$form = new Form($db); +$formfile = new FormFile($db); + +$title = $langs->trans("Partnership"); +llxHeader('', $title); + +$form = new Form($db); + +if ($memberid) { + $langs->load("members"); + + $member = new Adherent($db); + $result = $member->fetch($memberid); + + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } + + $adht->fetch($object->typeid); + + $head = member_prepare_head($member); + + print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'user'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($member, 'rowid', $linkback); + + print '
'; + + print '
'; + print ''; + + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; + } + + // Type + print '\n"; + + // Morphy + print ''; + print ''; + + // Company + print ''; + + // Civility + print ''; + print ''; + + print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$member->login.' 
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$member->getmorphylib().'
'.$langs->trans("Company").''.$member->company.'
'.$langs->trans("UserTitle").''.$member->getCivilityLabel().' 
'; + + print '
'; + + print dol_get_fiche_end(); + + $params = ''; + + print '
'; +} else { + dol_print_error('', 'Parameter rowid not defined'); +} + +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?rowid='.$memberid; + + print '
'; + print ''; + print ''; + print ''; + print ''; + + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + print dol_get_fiche_end(); + + print '
'; + print ''; + print '  '; + // print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($partnershipid || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("Partnership"), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?rowid='.$memberid; + + print '
'; + print ''; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + print load_fiche_titre($langs->trans("PartnershipDedicatedToThisMember", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $res = $object->fetch_optionals(); + + // $head = partnershipPrepareHead($object); + // print dol_get_fiche_head($head, 'card', $langs->trans("Partnership"), -1, $object->picto); + + $linkback = ''; + dol_banner_tab($object, 'id', $linkback, 0, 'rowid', 'ref'); + + $formconfirm = ''; + + // Close confirmation + if ($action == 'close') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClose'), $langs->trans('ConfirmClosePartnershipAsk', $object->ref), 'confirm_close', $formquestion, 'yes', 1); + } + // Reopon confirmation + if ($action == 'reopen') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToReopon'), $langs->trans('ConfirmReoponAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1); + } + + // Refuse confirmatio + if ($action == 'refuse') { + //Form to close proposal (signed or not) + $formquestion = array( + array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel', 'value' => '') // Field to complete private note (not replace) + ); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReasonDecline'), $text, 'confirm_refuse', $formquestion, '', 1, 250); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_member']); // Hide field already shown in banner + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // End of subscription date + $fadherent = new Adherent($db); + $fadherent->fetch($object->fk_member); + print ''; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans("SubscriptionEndDate").''; + if ($fadherent->datefin) { + print dol_print_date($fadherent->datefin, 'day'); + if ($fadherent->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } + } else { + if (!$adht->subscription) { + print $langs->trans("SubscriptionNotRecorded"); + if ($fadherent->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 ($fadherent->statut > 0) { + print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } + } + } + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + // Buttons for actions + + if ($action != 'presend') { + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (empty($reshook)) { + if ($object->status == $object::STATUS_DRAFT) { + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?rowid='.$memberid.'&action=edit', '', $permissiontoadd); + } + + // Show + if ($permissiontoadd) { + print dolGetButtonAction($langs->trans('ShowPartnership'), '', 'default', dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$object->id, '', $permissiontoadd); + } + + // Cancel + if ($permissiontoadd) { + if ($object->status == $object::STATUS_ACCEPTED) { + print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); + } + } + } + print '
'."\n"; + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 455c01d0337..5bba24a6a59 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -100,7 +100,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 41, 0, 15, 30, 0, 37, 42, 0, 25, 0); +$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 41, 0, 15, 30, 0, 37, 42, 0, 25, 0, 43, 0); // Name of SQL tables of dictionaries $tabname = array(); @@ -146,6 +146,7 @@ $tabname[39] = MAIN_DB_PREFIX."c_prospectcontactlevel"; $tabname[40] = MAIN_DB_PREFIX."c_stcommcontact"; $tabname[41] = MAIN_DB_PREFIX."c_transport_mode"; $tabname[42] = MAIN_DB_PREFIX."c_product_nature"; +$tabname[43] = MAIN_DB_PREFIX."c_productbatch_qcstatus"; // Dictionary labels $tablib = array(); @@ -191,6 +192,7 @@ $tablib[39] = "DictionaryProspectContactLevel"; $tablib[40] = "DictionaryProspectContactStatus"; $tablib[41] = "DictionaryTransportMode"; $tablib[42] = "DictionaryProductNature"; +$tablib[43] = "DictionaryBatchStatus"; // Requests to extract data $tabsql = array(); @@ -236,6 +238,7 @@ $tabsql[39] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_P $tabsql[40] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcommcontact"; $tabsql[41] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_transport_mode"; $tabsql[42] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_product_nature"; +$tabsql[43] = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_productbatch_qcstatus"; // Criteria to sort dictionaries $tabsqlsort = array(); @@ -281,6 +284,7 @@ $tabsqlsort[39] = "sortorder ASC"; $tabsqlsort[40] = "code ASC"; $tabsqlsort[41] = "code ASC"; $tabsqlsort[42] = "code ASC"; +$tabsqlsort[43] = "code ASC"; // Field names in select result for dictionary display $tabfield = array(); @@ -326,6 +330,7 @@ $tabfield[39] = "code,libelle,sortorder"; $tabfield[40] = "code,libelle,picto"; $tabfield[41] = "code,label"; $tabfield[42] = "code,label"; +$tabfield[43] = "code,label"; // Edit field names for editing a record $tabfieldvalue = array(); @@ -371,6 +376,7 @@ $tabfieldvalue[39] = "code,libelle,sortorder"; $tabfieldvalue[40] = "code,libelle,picto"; $tabfieldvalue[41] = "code,label"; $tabfieldvalue[42] = "code,label"; +$tabfieldvalue[43] = "code,label"; // Field names in the table for inserting a record $tabfieldinsert = array(); @@ -417,6 +423,7 @@ $tabfieldinsert[39] = "code,label,sortorder"; $tabfieldinsert[40] = "code,libelle,picto"; $tabfieldinsert[41] = "code,label"; $tabfieldinsert[42] = "code,label"; +$tabfieldinsert[43] = "code,label"; // Rowid name of field depending if field is autoincrement on or off.. // Use "" if id field is "rowid" and has autoincrement on @@ -464,6 +471,7 @@ $tabrowid[39] = "code"; $tabrowid[40] = "id"; $tabrowid[41] = ""; $tabrowid[42] = "rowid"; +$tabrowid[43] = "rowid"; // Condition to show dictionary in setup page $tabcond = array(); @@ -509,6 +517,7 @@ $tabcond[39] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_ $tabcond[40] = (!empty($conf->societe->enabled) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)); $tabcond[41] = !empty($conf->intracommreport->enabled); $tabcond[42] = !empty($conf->product->enabled); +$tabcond[43] = !empty($conf->product->enabled && !empty($conf->productbatch->enabled)); // List of help for fields $tabhelp = array(); @@ -554,6 +563,7 @@ $tabhelp[39] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp")); $tabhelp[41] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[42] = array('code'=>$langs->trans("EnterAnyCode")); +$tabhelp[43] = array('code'=>$langs->trans("EnterAnyCode")); // List of check for fields (NOT USED YET) $tabfieldcheck = array(); @@ -599,6 +609,7 @@ $tabfieldcheck[39] = array(); $tabfieldcheck[40] = array(); $tabfieldcheck[41] = array(); $tabfieldcheck[42] = array(); +$tabfieldcheck[43] = array(); // Complete all arrays with entries found into modules complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck); @@ -1968,6 +1979,9 @@ if ($id) { } elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_product_nature') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$value}); + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_productbatch_qcstatus') { + $langs->load("productbatch"); + $valuetoshow = $langs->trans($obj->{$value}); } $class .= ($class ? ' ' : '').'tddict'; if ($value == 'note' && $id == 10) { diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 386b3bcd9e1..a57df57d782 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -61,6 +61,8 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1), + 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1), + 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1), ); $error = 0; @@ -277,8 +279,13 @@ if ($action == 'edit') { });'; print ''; } + } elseif ($val['type'] == 'product') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + } } else { - print ''; + print ''; } print ''; } @@ -347,6 +354,14 @@ if ($action == 'edit') { } elseif ($conf->global->{$constname}==0) { print $langs->trans("NorProspectNorCustomer"); } + } elseif ($val['type'] == 'product') { + $product = new Product($db); + $resprod = $product->fetch($conf->global->{$constname}); + if ($resprod > 0) { + print $product->ref; + } elseif ($resprod < 0) { + setEventMessages(null, $object->errors, "errors"); + } } else { print $conf->global->{$constname}; } diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index fee54b6ce75..68e579697d3 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -333,13 +333,13 @@ if (empty($reshook)) { } } - // Si verif ok et action add, on ajoute la ligne + // If previous test is ok action is add, we add the line if ($ok && GETPOST('actionadd')) { // Add new entry $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields $sql .= $tabfieldinsert[$id]; - $sql .= ",active)"; + $sql .= ", active, enabled)"; $sql .= " VALUES("; // List of values @@ -390,7 +390,7 @@ if (empty($reshook)) { } $i++; } - $sql .= ", 1)"; + $sql .= ", 1, 1)"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index c3ef480d2ae..ce260a44a35 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -222,14 +222,23 @@ if (empty($reshook)) { $onlinepaymentenabled++; } if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + $substitutionarray['__ONLINEPAYMENTLINK_MEMBER__'] = getHtmlOnlinePaymentLink('member', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_DONATION__'] = getHtmlOnlinePaymentLink('donation', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_ORDER__'] = getHtmlOnlinePaymentLink('order', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_INVOICE__'] = getHtmlOnlinePaymentLink('invoice', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = getHtmlOnlinePaymentLink('contractline', $obj->source_id); + $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_DONATION__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); } else { - $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'member'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_DONATION__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'donation'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'order'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'contractline'.$obj->source_id, 2); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4e0faea04cb..0a094a8ab7b 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1680,6 +1680,28 @@ class Account extends CommonObject $this->owner_address = 'Owner address'; $this->country_id = 1; } + + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty($db, $origin_id, $dest_id) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."bank_url SET url_id = ".((int) $dest_id)." WHERE url_id = ".((int) $origin_id)." AND type='company'"; + + if (!$db->query($sql)) + { + //if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. + //$this->errors = $db->lasterror(); + return false; + } else { + return true; + } + } } diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index af60583118d..13814511297 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -44,6 +44,10 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); } } + if (preg_match('/__.*__/', $_FILES['userfile']['name'][$key])) { + $error++; + setEventMessages($langs->trans('ErrorWrongFileName'), null, 'errors'); + } } if (!$error) { @@ -64,7 +68,7 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) { } elseif (GETPOST('linkit', 'restricthtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) { $link = GETPOST('link', 'alpha'); if ($link) { - if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') { + if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://' && substr($link, 0, 7) != 'davs://') { $link = 'http://'.$link; } dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link, '', 0); @@ -172,8 +176,11 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because // this function is also applied when we upload and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). $filenameto = dol_string_nohtmltag($filenameto); - - if ($filenamefrom != $filenameto) { + if (preg_match('/__.*__/', $filenameto)) { + $error++; + setEventMessages($langs->trans('ErrorWrongFileName'), null, 'errors'); + } + if (!$error && $filenamefrom != $filenameto) { // Security: // Disallow file with some extensions. We rename them. // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c7954384fae..75844b77d4c 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -90,6 +90,9 @@ if (!$error && $massaction == 'confirm_presend') { if ($objecttmp->element == 'expensereport') { $thirdparty = new User($db); } + if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + $thirdparty = new Adherent($db); + } if ($objecttmp->element == 'holiday') { $thirdparty = new User($db); } @@ -107,6 +110,9 @@ if (!$error && $massaction == 'confirm_presend') { if ($objecttmp->element == 'expensereport') { $thirdpartyid = $objecttmp->fk_user_author; } + if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + $thirdpartyid = $objecttmp->fk_member; + } if ($objecttmp->element == 'holiday') { $thirdpartyid = $objecttmp->fk_user; } @@ -250,6 +256,10 @@ if (!$error && $massaction == 'confirm_presend') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user_author); $sendto = $fuser->email; + } elseif ($objectobj->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + $fadherent = new Adherent($db); + $fadherent->fetch($objectobj->fk_member); + $sendto = $fadherent->email; } elseif ($objectobj->element == 'holiday') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c46da48b858..4b55b52dba0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3820,6 +3820,11 @@ abstract class CommonObject $classpath = 'projet/class'; $classfile = 'project'; $classname = 'Project'; + } elseif ($objecttype == 'conferenceorboothattendee') { + $classpath = 'eventorganization/class'; + $classfile = 'conferenceorboothattendee'; + $classname = 'ConferenceOrBoothAttendee'; + $module = 'eventorganization'; } // Here $module, $classfile and $classname are set diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index e104b01a9ae..7cf9978d32b 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -2029,7 +2029,7 @@ class FormFile print ''.dol_print_date($link->datea, "dayhour", "tzuser").''; print ''; print ''; - print ''.img_edit().''; // id= is included into $param + print ''.img_edit().''; // id= is included into $param if ($permissiontodelete) { print '   '.img_delete().''; // id= is included into $param } else { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index f56b9f6070e..96f6ee0a741 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1594,6 +1594,9 @@ class FormMail extends Form if ($conf->adherent->enabled) { $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember'; } + if ($conf->donation->enabled) { + $tmparray['__SECUREKEYPAYMENT_DONATION__'] = 'SecureKeyPAYMENTUniquePerDonation'; + } if ($conf->facture->enabled) { $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice'; } @@ -1603,6 +1606,23 @@ class FormMail extends Form if ($conf->contrat->enabled) { $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'SecureKeyPAYMENTUniquePerContractLine'; } + + //Online payement link + if ($conf->adherent->enabled) { + $tmparray['__ONLINEPAYMENTLINK_MEMBER__'] = 'OnlinePaymentLinkUniquePerMember'; + } + if ($conf->donation->enabled) { + $tmparray['__ONLINEPAYMENTLINK_DONATION__'] = 'OnlinePaymentLinkUniquePerDonation'; + } + if ($conf->facture->enabled) { + $tmparray['__ONLINEPAYMENTLINK_INVOICE__'] = 'OnlinePaymentLinkUniquePerInvoice'; + } + if ($conf->commande->enabled) { + $tmparray['__ONLINEPAYMENTLINK_ORDER__'] = 'OnlinePaymentLinkUniquePerOrder'; + } + if ($conf->contrat->enabled) { + $tmparray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = 'OnlinePaymentLinkUniquePerContractLine'; + } } } else { /* No need to show into tooltip help, option is not enabled diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 356b0aba5e7..c0a8844b572 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -102,7 +102,7 @@ if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) { var lastopendropdown = null; // Click onto the link "link to" or "hamburger", toggle dropdown - $(".dropdown dt a").on(\'click\', function () { + $(document).on(\'click\', \'.dropdown dt a\', function () { console.log("toggle dropdown dt a"); //$(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\'); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2085c3f2320..cf8f247d54e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6809,6 +6809,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__'; $substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__'; $substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__'; + $substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = 'Login and pass of the external user account'; /*$substitutionarray['__MEMBER_NOTE_PUBLIC__'] = '__MEMBER_NOTE_PUBLIC__'; $substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/ } @@ -6884,6 +6885,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, } $substitutionarray['__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname : ''); $substitutionarray['__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname : ''); + $substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = ''; if (method_exists($object, 'getFullName')) { $substitutionarray['__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs); } @@ -9384,7 +9386,8 @@ function getDictvalue($tablename, $field, $id, $checkentity = false, $rowidfield if (!isset($dictvalues[$tablename])) { $dictvalues[$tablename] = array(); - $sql = 'SELECT * FROM '.$tablename.' WHERE 1'; // Here select * is allowed as it is generic code and we don't have list of fields + + $sql = 'SELECT * FROM '.$tablename.' WHERE 1 = 1'; // Here select * is allowed as it is generic code and we don't have list of fields if ($checkentity) { $sql .= ' AND entity IN (0,'.getEntity($tablename).')'; } @@ -9673,6 +9676,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = $class = 'butAction'; if ($actionType == 'danger' || $actionType == 'delete') { $class = 'butActionDelete'; + if (strpos($url, 'token=') === false) $url .= '&token='.newToken(); } $attr = array( diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 494a92d33e3..59d9eb4aa4c 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -3,6 +3,7 @@ * Copyright (C) 2013 Marcos García * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Abbes Bahfir + * Copyright (C) 2021 Waël Almoman * * 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 @@ -155,7 +156,7 @@ function getValidOnlinePaymentMethods($paymentmethod = '') } /** - * Return string with full Url + * Return string with full online payment Url * * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) * @param string $ref Ref of object @@ -178,6 +179,22 @@ function showOnlinePaymentUrl($type, $ref) return $out; } +/** + * Return string with HTML link for online payment + * + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @param string $label Text or HTML tag to display, if empty it display the URL + * @return string Url string + */ +function getHtmlOnlinePaymentLink($type, $ref, $label = '') +{ + $url = getOnlinePaymentUrl(0, $type, $ref); + $label = $label ? $label : $url; + return''.$label.''; +} + + /** * Return string with full Url * diff --git a/htdocs/core/modules/member/modules_member.class.php b/htdocs/core/modules/member/modules_member.class.php index 1ff1ffc3d30..3a1b4edcc1d 100644 --- a/htdocs/core/modules/member/modules_member.class.php +++ b/htdocs/core/modules/member/modules_member.class.php @@ -20,10 +20,6 @@ */ -/** - * \class ModeleProductCode - * \brief Parent class for product code generators - */ /** * \file htdocs/core/modules/member/modules_member.class.php diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 6b69c6b7af0..18f46fda70f 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019 Maxime Kohlhaas + * Copyright (C) 2021 Ferran Marcet * * 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 @@ -315,6 +316,142 @@ class modBom extends DolibarrModules $this->export_sql_end[$r] .= ' AND t.entity IN ('.getEntity('bom').')'; $r++; /* END MODULEBUILDER EXPORT BILLOFMATERIALS */ + + // Imports + //-------- + $r = 0; + //Import BOM Header + + $r++; + $this->import_code[$r] = 'bom_'.$r; + $this->import_label[$r] = 'BillOfMaterials'; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = []; + $this->import_tables_array[$r] = ['b' => MAIN_DB_PREFIX.'bom_bom', 'extra' => MAIN_DB_PREFIX.'bom_bom_extrafields']; + $this->import_tables_creator_array[$r] = ['b' => 'fk_user_creat']; // Fields to store import user id + $this->import_fields_array[$r] = [ + 'b.ref' => 'Document Ref*', + 'b.label' => 'BomLabel*', + 'b.fk_product' => 'ProductRef*', + 'b.description' => 'Description', + 'b.note_public' => 'Note', + 'b.note_private' => 'NotePrivate', + 'b.fk_warehouse' => 'WarehouseRef', + 'b.qty' => 'Qty', + 'b.efficiency' => 'Efficiency', + 'b.duration' => 'Duration', + 'b.date_creation' => 'DateCreation', + 'b.date_valid' => 'DateValid', + 'b.fk_user_modif' => 'ModifiedById', + 'b.fk_user_valid' => 'ValidatedById', + 'b.model_pdf' => 'Model', + 'b.status' => 'Status*', + 'b.bomtype' => 'BomType*' + + ]; + + // Add extra fields + $import_extrafield_sample = []; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bom' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); + + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $import_extrafield_sample[$fieldname] = $fieldlabel; + } + } + // End add extra fields + + $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bom']; + $this->import_regex_array[$r] = [ + 'b.ref' => '(CPV\d{4}-\d{4}|BOM\d{4}-\d{4}|PROV.{1,32}$)' + ]; + + $this->import_updatekeys_array[$r] = ['b.ref' => 'Ref']; + $this->import_convertvalue_array[$r] = [ + 'b.fk_product' => [ + 'rule' => 'fetchidfromref', + 'file' => '/product/class/product.class.php', + 'class' => 'Product', + 'method' => 'fetch', + 'element' => 'Product' + ], + 'b.fk_warehouse' => [ + 'rule' => 'fetchidfromref', + 'file' => '/product/stock/class/entrepot.class.php', + 'class' => 'Entrepot', + 'method' => 'fetch', + 'element' => 'Warehouse' + ], + 'b.fk_user_valid' => [ + 'rule' => 'fetchidfromref', + 'file' => '/user/class/user.class.php', + 'class' => 'User', + 'method' => 'fetch', + 'element' => 'user' + ], + 'b.fk_user_modif' => [ + 'rule' => 'fetchidfromref', + 'file' => '/user/class/user.class.php', + 'class' => 'User', + 'method' => 'fetch', + 'element' => 'user' + ], + ]; + + //Import BOM Lines + $r++; + $this->import_code[$r] = 'bom_lines_'.$r; + $this->import_label[$r] = 'BillOfMaterialsLine'; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = []; + $this->import_tables_array[$r] = ['bd' => MAIN_DB_PREFIX.'bom_bomline', 'extra' => MAIN_DB_PREFIX.'bom_bomline_extrafields']; + $this->import_fields_array[$r] = [ + 'bd.fk_bom' => 'Document Ref*', + 'bd.fk_product' => 'ProductRef', + 'bd.fk_bom_child' => 'BOMChild', + 'bd.description' => 'Description', + 'bd.qty' => 'LineQty', + 'bd.qty_frozen' => 'LineIsFrozen', + 'bd.disable_stock_change' => 'Disable Stock Change', + 'bd.efficiency' => 'Efficiency', + 'bd.position' => 'LinePosition' + ]; + + // Add extra fields + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bomline' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + } + } + // End add extra fields + + $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bomline']; + $this->import_regex_array[$r] = []; + $this->import_updatekeys_array[$r] = ['bd.fk_bom' => 'BOM Id']; + $this->import_convertvalue_array[$r] = [ + 'bd.fk_bom' => [ + 'rule' => 'fetchidfromref', + 'file' => '/bom/class/bom.class.php', + 'class' => 'BOM', + 'method' => 'fetch', + 'element' => 'bom' + ], + 'bd.fk_product' => [ + 'rule' => 'fetchidfromref', + 'file' => '/product/class/product.class.php', + 'class' => 'Product', + 'method' => 'fetch', + 'element' => 'Product' + ], + ]; } /** diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index 8b3b0cdb2c4..d12cd610238 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -180,10 +180,10 @@ class modPartnership extends DolibarrModules $tabtoadd = (!empty(getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR')) && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') ? 'member' : 'thirdparty'; if ($tabtoadd == 'member') { - $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?rowid=__ID__'); $fk_mainmenu = "members"; } else { - $this->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $this->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/societe/partnership.php?socid=__ID__'); $fk_mainmenu = "companies"; } @@ -253,12 +253,12 @@ class modPartnership extends DolibarrModules // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week - $statusatinstall=0; $arraydate=dol_getdate(dol_now()); $datestart=dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>$statusatinstall, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 1 => array('priority'=>61, 'label'=>'CheckDolibarrBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), ); // Permissions provided by this module diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index d34213f062c..5cb7a7f0c38 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -198,11 +198,25 @@ class modTakePos extends DolibarrModules $r++; $this->rights[$r][0] = 50151; - $this->rights[$r][1] = 'Use Point Of Sale'; + $this->rights[$r][1] = 'Use Point Of Sale (record a sale, add products, record payment)'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'run'; + $r++; + $this->rights[$r][0] = 50152; + $this->rights[$r][1] = 'Can modify added sales lines (prices, discount)'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'editlines'; + + $r++; + $this->rights[$r][0] = 50153; + $this->rights[$r][1] = 'Edit ordered sales lines (useful only when option "Order printers" has been enabled). Allow to edit sales lines even after the order has been printed'; + $this->rights[$r][2] = 'a'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'editorderedlines'; + // Main menu entries $this->menu = array(); // List of menus to add diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index f2f75031d3b..1806453dc57 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -231,10 +231,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders $objphoto->fetch($object->lines[$i]->fk_product); if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; + $pdir = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; } else { - $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; + $pdir = get_exdir($objphoto->id, 0, 0, 0, $objphoto, 'product'); $dir = $conf->product->dir_output.'/'.$pdir; } diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index de283265931..a16e1db2b01 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -246,13 +246,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $objphoto->fetch($object->lines[$i]->fk_product); if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; + $pdir = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; } else { - $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; + $pdir = get_exdir($objphoto->id, 0, 0, 0, $objphoto, 'product'); $dir = $conf->product->dir_output.'/'.$pdir; } - $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { $filename = $obj['photo']; diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index de10465a736..62aafc2fdb5 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -151,6 +151,10 @@ if ($action == 'presend') { $fuser = new User($db); $fuser->fetch($object->fk_user_author); $liste['thirdparty'] = $fuser->getFullName($outputlangs)." <".$fuser->email.">"; + } elseif ($object->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + $fadherent = new Adherent($db); + $fadherent->fetch($object->fk_member); + $liste['member'] = $fadherent->getFullName($outputlangs)." <".$fadherent->email.">"; } elseif ($object->element == 'societe') { foreach ($object->thirdparty_and_contact_email_array(1) as $key => $value) { $liste[$key] = $value; diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 79b00f01590..2848bd3d48c 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -127,6 +127,10 @@ if ($massaction == 'presend') { $fuser = new User($db); $fuser->fetch($thirdpartyid); $liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">"; + } elseif ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + $fadherent = new Adherent($db); + $fadherent->fetch($objecttmp->fk_member); + $liste['member'] = $fadherent->getFullName($langs)." <".$fadherent->email.">"; } else { $soc = new Societe($db); $soc->fetch($thirdpartyid); diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 6c68cd827e7..f5f8f1507bf 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -237,7 +237,18 @@ class ConferenceOrBooth extends ActionComm */ public function fetch($id, $ref = null, $ref_ext = '', $email_msgid = '') { + global $dolibarr_main_url_root, $dolibarr_main_instance_unique_id, $conf, $langs; + $result = parent::fetch($id, $ref, $ref_ext, $email_msgid); + + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$id; + + $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + $link_subscription .= '&securekey='.urlencode($encodedsecurekey); + + $this->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); + $this->pubregister = $link_subscription; + $this->getActionCommFields(); return $result; } diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 15b52eda038..f983994c4ec 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -493,16 +493,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field //unset($object->fields['fk_project']); // Hide field already shown in banner //unset($object->fields['fk_soc']); // Hide field already shown in banner - global $dolibarr_main_url_root; - - $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$encodedid; - - $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); - $link_subscription .= '&securekey='.urlencode($encodedsecurekey); - - $object->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); - $object->pubregister = $link_subscription; $keyforbreak='pubregister'; include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index c2bccfaa517..3e480efca54 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -39,6 +39,8 @@ if ($conf->categorie->enabled) { // Load translation files required by the page $langs->loadLangs(array("eventorganization", "other")); +global $dolibarr_main_url_root, $dolibarr_main_instance_unique_id; + $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? @@ -360,6 +362,14 @@ if ($projectid > 0) { } print ''; + // Link to the vote/register page + print ''.$langs->trans("RegisterPage").''; + $linkregister = $dolibarr_main_url_root.'/public/project/index.php?id='.$project->id; + $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 2); + $linkregister .= '&securekey='.urlencode($encodedsecurekey); + print ''.$linkregister.''; + print ''; + // Other attributes $cols = 2; $objectconf=$object; diff --git a/htdocs/install/mysql/data/llx_00_c_country.sql b/htdocs/install/mysql/data/llx_00_c_country.sql index 88df2349391..fa2b4339983 100644 --- a/htdocs/install/mysql/data/llx_00_c_country.sql +++ b/htdocs/install/mysql/data/llx_00_c_country.sql @@ -6,6 +6,7 @@ -- Copyright (C) 2005-2009 Regis Houssin -- Copyright (C) 2007 Patrick Raguin -- Copyright (C) 2014 Alexandre Spangaro +-- Copyright (C) 2021 Udo Tamm -- -- 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 @@ -50,7 +51,7 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (19 INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (20,'SE','SWE','Sweden',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (21,'CI','CIV','Côte d''Ivoire',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (22,'SN','SEN','Senegal',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (23,'AR','ARG','Argentine',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (23,'AR','ARG','Argentina',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (24,'CM','CMR','Cameroun',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (25,'PT','PRT','Portugal',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (26,'SA','SAU','Saudi Arabia',1,0); @@ -59,21 +60,21 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (28 INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (29,'SG','SGP','Singapour',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (30,'AF','AFG','Afghanistan',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (31,'AX','ALA','Iles Aland',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (32,'AL','ALB','Albanie',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (32,'AL','ALB','Albania',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (33,'AS','ASM','Samoa américaines',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (34,'AD','AND','Andorre',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (34,'AD','AND','Andorra',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (35,'AO','AGO','Angola',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (36,'AI','AIA','Anguilla',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (37,'AQ','ATA','Antarctique',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (38,'AG','ATG','Antigua-et-Barbuda',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (39,'AM','ARM','Arménie',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (41,'AT','AUT','Autriche',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (39,'AM','ARM','Armenia',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (41,'AT','AUT','Austria',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (42,'AZ','AZE','Azerbaïdjan',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (43,'BS','BHS','Bahamas',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (44,'BH','BHR','Bahreïn',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (45,'BD','BGD','Bangladesh',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (46,'BB','BRB','Barbade',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (47,'BY','BLR','Biélorussie',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (47,'BY','BLR','Belarus',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (48,'BZ','BLZ','Belize',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (49,'BJ','BEN','Bénin',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (50,'BM','BMU','Bermudes',1,0); diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index fabbbf2e700..5ca98be8545 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -35,6 +35,6 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_u INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskConf', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventConfRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__(Sincerely)__

__MYCOMPANY_NAME__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); diff --git a/htdocs/install/mysql/data/llx_c_productbatch_qcstatus.sql b/htdocs/install/mysql/data/llx_c_productbatch_qcstatus.sql new file mode 100644 index 00000000000..7e0bb6661f6 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_productbatch_qcstatus.sql @@ -0,0 +1,28 @@ +-- Copyright (C) 2021 Noé Cendrier +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- + +-- +-- Do not place a comment at the end of the line, this file is parsed when +-- from the install and all '--' are removed. +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + +INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('OK', 'InWorkingOrder', 1); +INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('KO', 'OutOfOrder', 1); + diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index e69cad3564c..5dfeac1d222 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -587,4 +587,5 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) -- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL; -- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL; +ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index af6c2f48f50..e26930739a7 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -59,11 +59,11 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','NL','HU','IE','IM','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI'); +ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); + -- For v14 -ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); - create table llx_accounting_groups_account ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -157,6 +157,18 @@ CREATE TABLE llx_workstation_workstation_usergroup( fk_workstation integer ) ENGINE=innodb; +CREATE TABLE llx_c_producbatch_qcstatus( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer NOT NULL DEFAULT 1, + code varchar(16) NOT NULL, + label varchar(50) NOT NULL, + active integer DEFAULT 1 NOT NULL +) ENGINE=innodb; + +ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code, entity); + +INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('OK', 'InWorkingOrder', 1); +INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('KO', 'OutOfOrder', 1); ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30); ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30); @@ -187,6 +199,7 @@ ALTER TABLE llx_mrp_production ADD COLUMN origin_type varchar(10) AFTER origin_i ALTER TABLE llx_fichinter ADD COLUMN last_main_doc varchar(255) AFTER model_pdf; ALTER TABLE llx_projet ADD COLUMN last_main_doc varchar(255) AFTER model_pdf; +ALTER TABLE llx_expensereport ADD COLUMN last_main_doc varchar(255) DEFAULT NULL AFTER model_pdf; create table llx_payment_vat ( @@ -220,7 +233,7 @@ ALTER TABLE llx_tva ALTER COLUMN paye SET DEFAULT 0; INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskConf', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventConfRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__(Sincerely)__

__MYCOMPANY_NAME__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); @@ -413,8 +426,9 @@ CREATE TABLE llx_partnership( note_private text, note_public text, last_main_doc varchar(255), - count_last_url_check_error integer DEFAULT '0', - import_key varchar(14), + count_last_url_check_error integer DEFAULT '0', + last_check_backlink datetime NULL, + import_key varchar(14), model_pdf varchar(255) ) ENGINE=innodb; @@ -435,7 +449,11 @@ create table llx_partnership_extrafields ALTER TABLE llx_partnership_extrafields ADD INDEX idx_partnership_fk_object(fk_object); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'member', '(AlertStatusPartnershipExpiration)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourMembershipWillSoonExpireTopic)__', 0, '\n

Dear __MEMBER_FULLNAME__,

\n__(YourMembershipWillSoonExpireContent)__

\n
\n\n __(Sincerely)__
\n __[PARTNERSHIP_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipWillSoonBeCanceled)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipWillSoonBeCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipWillSoonBeCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipRefusedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipAccepted)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipAcceptedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipAcceptedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +ALTER TABLE llx_adherent ADD COLUMN url varchar(255) NULL AFTER email; ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid; ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid; diff --git a/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql new file mode 100644 index 00000000000..9ffa27bc3a5 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2021 Noé Cendrier +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code, entity); diff --git a/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql new file mode 100644 index 00000000000..73daa56067a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2012-2017 Noé Cendrier +-- +-- 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 +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +CREATE TABLE llx_c_productbatch_qcstatus +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer NOT NULL DEFAULT 1, + code varchar(16) NOT NULL, + label varchar(50) NOT NULL, + active integer DEFAULT 1 NOT NULL +)ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d803593bc3e..a69bf9e9ca2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -966,6 +966,8 @@ Permission23003=Delete Scheduled job Permission23004=Execute Scheduled job Permission50101=Use Point of Sale (SimplePOS) Permission50151=Use Point of Sale (TakePOS) +Permission50152=Edit sales lines +Permission50153=Edit ordered sales lines Permission50201=Read transactions Permission50202=Import transactions Permission50330=Read objects of Zapier @@ -1045,6 +1047,7 @@ DictionaryOpportunityStatus=Lead status for project/lead DictionaryExpenseTaxCat=Expense report - Transportation categories DictionaryExpenseTaxRange=Expense report - Range by transportation category DictionaryTransportMode=Intracomm report - Transport mode +DictionaryBatchStatus=Product lot/serial Quality Control status TypeOfUnit=Type of unit SetupSaved=Setup saved SetupNotSaved=Setup not saved @@ -1434,6 +1437,7 @@ MemberMainOptions=Main options AdherentLoginRequired= Manage a Login for each member AdherentMailRequired=Email required to create a new member MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members (validation or new subscription) is on by default +MemberCreateAnExternalUserForSubscriptionValidated=Create an external user login for each new member subscription validated VisitorCanChooseItsPaymentMode=Visitor can choose from available payment modes MEMBER_REMINDER_EMAIL=Enable automatic reminder by email of expired subscriptions. Note: Module %s must be enabled and correctly setup to send reminders. MembersDocModules=Document templates for documents generated from member record diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index c4f88a8d5b3..a1155b0f57c 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -299,3 +299,4 @@ WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So y ErrorActionCommPropertyUserowneridNotDefined=User's owner is required ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Event Type dictionary CheckVersionFail=Version check fail +ErrorWrongFileName=Name of the file cannot have __SOMETHING__ in it diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index a9d31c1dbaf..9f75374f2a0 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -82,6 +82,8 @@ EventOrganizationICSLink=Link ICS for events ConferenceOrBoothInformation=Conference Or Booth informations Attendees = Attendees EVENTORGANIZATION_SECUREKEY = Secure Key of the public registration link to a conference +SERVICE_BOOTH_LOCATION = Service used for the invoice row about a booth location +SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION = Service used for the invoice row about an attendee subscription to a conference # # Status # @@ -94,8 +96,27 @@ EvntOrgCancelled = Cancelled # # Public page # +RegisterPage = Page for conferences or booth +EvntOrgRegistrationWelcomeMessage = Welcome on the conference or booth suggestion page. +EvntOrgRegistrationHelpMessage = Here, you can suggest a new conference or a new booth for the project +SuggestConference = Suggest a new conference +SuggestBooth = Suggest a booth +ViewAndVote = View and vote for suggested events PublicAttendeeSubscriptionPage = Public link of registration to a conference MissingOrBadSecureKey = The security key is invalid or missing -EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference -EvntOrgStartDuration = This conference starts on -EvntOrgEndDuration = and ends on +EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference : '%s' +EvntOrgDuration = This conference starts on %s and ends on %s. +ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s. +# +# SubscriptionOk page +# +SubscriptionOk = Your subscription to this conference has been validated +# +# Subscription validation mail +# +ConfAttendeeSubscriptionConfirmation = Confirmation of your subscription to a conference +# +# Payment page +# +Attendee = Participant +PaymentConferenceAttendee = Paiement de participation à une conférence diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b6d2e4c4ef8..d91989190e0 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1072,6 +1072,7 @@ ValidFrom=Valid from ValidUntil=Valid until NoRecordedUsers=No users ToClose=To close +ToRefuse=To refuse ToProcess=To process ToApprove=To approve GlobalOpenedElemView=Global view @@ -1126,6 +1127,7 @@ UpdateForAllLines=Update for all lines OnHold=On hold Civility=Civility AffectTag=Affect Tag +CreateExternalUser=Create external user ConfirmAffectTag=Bulk Tag Affect ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)? CategTypeNotFound=No tag type found for type of records diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 5bd1a545bfa..6f5e47591f3 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -213,3 +213,4 @@ SendReminderForExpiredSubscription=Send reminder by email to members when subscr MembershipPaid=Membership paid for current period (until %s) YouMayFindYourInvoiceInThisEmail=You may find your invoice attached to this email XMembersClosed=%s member(s) closed +XExternalUserCreated=%s external user(s) created diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 7681449755e..df9619533de 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -16,41 +16,65 @@ # # Generic # -ModulePartnershipName = Partnership management -PartnershipDescription = Module Partnership management +ModulePartnershipName=Partnership management +PartnershipDescription=Module Partnership management PartnershipDescriptionLong= Module Partnership management # # Menu # -NewPartnership = New Partnership -ListOfPartnerships = List of partnership +NewPartnership=New Partnership +ListOfPartnerships=List of partnership # # Admin page # -PartnershipSetup = Partnership setup -PartnershipAbout = About Partnership -PartnershipAboutPage = Partnership about page - +PartnershipSetup=Partnership setup +PartnershipAbout=About Partnership +PartnershipAboutPage=Partnership about page +partnershipforthirdpartyormember=Partnership is for a 'thirdparty' or for a 'member' +PARTNERSHIP_IS_MANAGED_FOR=Partnership managed for +PARTNERSHIP_BACKLINKS_TO_CHECK=Backlinks to check +PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL=Nb of days before cancel status of partnership when subscription is expired # # Object # +DeletePartnership=Delete a partnership +PartnershipDedicatedToThisThirdParty=Partnership dedicated to this third party +PartnershipDedicatedToThisMember=Partnership dedicated to this member DatePartnershipStart=Start date DatePartnershipEnd=End date +ReasonDecline=Decline reason +ReasonDeclineOrCancel=Decline reason +PartnershipAlreadyExist=Partnership already exist +ShowPartnership=Show partnership +BacklinkNotFoundOnPartnerWebsite=Backlink not found on partner website +ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership? # # Template Mail # +SendingEmailOnPartnershipWillSoonBeCanceled=Partnership will soon be canceled +SendingEmailOnPartnershipRefused=Partnership refused +SendingEmailOnPartnershipAccepted=Partnership accepted +SendingEmailOnPartnershipCanceled=Partnership canceled +YourPartnershipWillSoonBeCanceledTopic=Partnership will soon be canceled +YourPartnershipRefusedTopic=Partnership refused +YourPartnershipAcceptedTopic=Partnership accepted +YourPartnershipCanceledTopic=Partnership canceled + +YourPartnershipWillSoonBeCanceledContent=We inform you that your partnership will soon be canceled (Backlink not found) +YourPartnershipRefusedContent=We inform you that your partnership request has been refused. +YourPartnershipAcceptedContent=We inform you that your partnership request has been accepted. +YourPartnershipCanceledContent=We inform you that your partnership has been canceled. # # Status # -PartnershipDraft = Draft -PartnershipAccepted = Accepted -PartnershipRefused = Refused -PartnershipCanceled = Canceled - +PartnershipDraft=Draft +PartnershipAccepted=Accepted +PartnershipRefused=Refused +PartnershipCanceled=Canceled PartnershipManagedFor=Partners are \ No newline at end of file diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index e7105c544ed..450d0285819 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -1,4 +1,4 @@ -# ProductBATCH language file - en_US - ProductBATCH +# ProductBATCH language file - Source file is en_US - ProductBATCH ManageLotSerial=Use lot/serial number ProductStatusOnBatch=Yes (lot required) ProductStatusOnSerial=Yes (unique serial number required) @@ -39,5 +39,7 @@ ManufacturingDate=Manufacturing date DestructionDate=Destruction date FirstUseDate=First use date QCFrequency=Quality control frequency (in days) -InWorkingOrder=In working order + +#Traceability - qc status OutOfOrder=Out of order +InWorkingOrder=In working order diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 44e4aba52ed..e9b5ddf5c4e 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1044,6 +1044,7 @@ DictionaryOpportunityStatus=Statut d'opportunités pour les affaires/projets DictionaryExpenseTaxCat=Note de frais - catégories de déplacement DictionaryExpenseTaxRange=Note de frais - Tri par catégorie de déplacement DictionaryTransportMode=Déclaration d'échanges intracommunautaires - Mode de transport +DictionaryBatchStatus=État de qualité du lot/série (produits) TypeOfUnit=Type d'unité SetupSaved=Configuration sauvegardée SetupNotSaved=Configuration non enregistrée diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index 68714707a9c..337af188fe1 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -1,4 +1,4 @@ -# ProductBATCH language file - en_US - ProductBATCH +# ProductBATCH language file - Source file is en_US - ProductBATCH ManageLotSerial=Utiliser les numéros de lots/série ProductStatusOnBatch=Oui (Lot/Série requis) ProductStatusOnSerial=Oui (numéro de série unique requis) @@ -30,8 +30,8 @@ BatchLotNumberingModules=Options pour la génération automatique de produits en BatchSerialNumberingModules=Options pour la génération automatique de produits en lots gérés par numéros de série ManageLotMask=Masque personnalisé CustomMasks=Ajoute une option pour définir le masque dans la fiche produit -LotProductTooltip=Ajoute une option dans la fiche produit pour définir un masque de numéro de lot dédié -SNProductTooltip=Ajoute une option dans la fiche produit pour définir un masque de numéro de série dédié +LotProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de lot +SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série QtyToAddAfterBarcodeScan=Quantité à ajouter pour chaque code à barres/lot/série scanné LifeTime=Durée de vie (en jours) EndOfLife=Date de fin de vie diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index d687faebfb8..9007eab60cc 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -82,6 +82,7 @@ $arrayofparameters = array( //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), + //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), ); $error = 0; @@ -299,6 +300,11 @@ if ($action == 'edit') { });'; print ''; } + } elseif ($val['type'] == 'product') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + } } else { print ''; } @@ -365,8 +371,16 @@ if ($action == 'edit') { } elseif ($conf->global->{$constname}==0) { print $langs->trans("NorProspectNorCustomer"); } + } elseif ($val['type'] == 'product') { + $product = new Product($db); + $resprod = $product->fetch($conf->global->{$constname}); + if ($resprod > 0) { + print $product->ref; + } elseif ($resprod < 0) { + setEventMessages(null, $object->errors, "errors"); + } } else { - print $conf->global->{$constname}; + print $conf->global->{$constname}; } print ''; } diff --git a/htdocs/partnership/admin/about.php b/htdocs/partnership/admin/about.php new file mode 100644 index 00000000000..0d3fb11c4e3 --- /dev/null +++ b/htdocs/partnership/admin/about.php @@ -0,0 +1,101 @@ + + * Copyright (C) 2021 Dorian Laurent + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file partnership/admin/about.php + * \ingroup partnership + * \brief About page of module Partnership. + */ + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +// Libraries +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once '../lib/partnership.lib.php'; + +// Translations +$langs->loadLangs(array("errors", "admin", "partnership@partnership")); + +// Access control +if (!$user->admin) { + accessforbidden(); +} + +// Parameters +$action = GETPOST('action', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + + +/* + * Actions + */ + + +/* + * View + */ + +$form = new Form($db); + +$page_name = "PartnershipAbout"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = ''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); + +// Configuration header +$head = partnershipAdminPrepareHead(); +print dol_get_fiche_head($head, 'about', '', 0, 'partnership@partnership'); + +require_once DOL_DOCUMENT_ROOT.'/core/modules/modPartnership.class.php'; +$tmpmodule = new modPartnership($db); +print $tmpmodule->getDescLong(); + +// Page end +print dol_get_fiche_end(); +llxFooter(); +$db->close(); diff --git a/htdocs/partnership/admin/setup.php b/htdocs/partnership/admin/setup.php index aac962ede72..d681274106c 100644 --- a/htdocs/partnership/admin/setup.php +++ b/htdocs/partnership/admin/setup.php @@ -82,36 +82,21 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setting') { require_once DOL_DOCUMENT_ROOT."/core/modules/modPartnership.class.php"; - $partnership = new modPartnership($db); - $value = GETPOST('managed_for', 'alpha'); - - - $modulemenu = ($value == 'member') ? 'member' : 'thirdparty'; + $modulemenu = (GETPOST('PARTNERSHIP_IS_MANAGED_FOR', 'alpha') == 'member') ? 'member' : 'thirdparty'; $res = dolibarr_set_const($db, "PARTNERSHIP_IS_MANAGED_FOR", $modulemenu, 'chaine', 0, '', $conf->entity); - $partnership->tabs = array(); - if ($modulemenu == 'member') { - $partnership->tabs[] = array('data'=>'member:+partnership:Partnership:partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); - $fk_mainmenu = "members"; - } else { - $partnership->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); - $fk_mainmenu = "companies"; - } - - foreach ($partnership->menu as $key => $menu) { - $partnership->menu[$key]['mainmenu'] = $fk_mainmenu; - - if ($menu['leftmenu'] == 'partnership') - $partnership->menu[$key]['fk_menu'] = 'fk_mainmenu='.$fk_mainmenu; - else $partnership->menu[$key]['fk_menu'] = 'fk_mainmenu='.$fk_mainmenu.',fk_leftmenu=partnership'; - } + $partnership = new modPartnership($db); $error += $partnership->delete_tabs(); $error += $partnership->insert_tabs(); $error += $partnership->delete_menus(); $error += $partnership->insert_menus(); + + if (GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int')) + dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "PARTNERSHIP_BACKLINKS_TO_CHECK", GETPOST("PARTNERSHIP_BACKLINKS_TO_CHECK"), 'chaine', 0, '', $conf->entity); } if ($action) { @@ -120,6 +105,8 @@ if ($action) { } else { setEventMessages($langs->trans("SetupNotError"), null, 'errors'); } + header("Location: ".$_SERVER['PHP_SELF']); + exit; } /* @@ -154,19 +141,48 @@ print ''; print ''; -// Default partnership price base type -print ''; -print ''; -print ''; + +print ''; +print ''; +print ''; +print ''; print ''; -print '
'.$langs->trans("PartnershipManagedFor").''; - print ''; -print '
'.$langs->trans("Setting").''.$langs->trans("Value").''.$langs->trans("Examples").'
'; +print ''.$langs->trans("PARTNERSHIP_IS_MANAGED_FOR").''; +print ''; +print ''; +print ''; +print ''.$langs->trans("partnershipforthirdpartyormember").''; +print ''; + + +if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + print ''.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").''; + print ''; + $dnbdays = '7'; + $backlinks = (!empty($conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL)) ? $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL : $dnbdays; + print ''; + print ''; + print ''.$dnbdays.''; + print ''; +} + + +print ''.$langs->trans("PARTNERSHIP_BACKLINKS_TO_CHECK").''; +print ''; +$dbacklinks = 'dolibarr.org|dolibarr.fr|dolibarr.es'; +$backlinks = (!empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK)) ? $conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK : $dbacklinks; +print ''; +print ''; +print ''.$dbacklinks.''; +print ''; + + +print ''; print '
'; print ''; print '
'; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 1dab8890050..a42e12fd412 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -100,26 +100,7 @@ class Partnership extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1,), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), - 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), - 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), - 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>4, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'Refused', '9'=>'Canceled'),), - 'fk_member' => array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>51, 'notnull'=>-1, 'visible'=>1, 'index'=>1,), - 'date_partnership_start' => array('type'=>'datetime', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), - 'date_partnership_end' => array('type'=>'datetime', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>1,), - 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), - 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), - ); + public $fields=array(); public $rowid; public $ref; public $fk_soc; @@ -137,6 +118,7 @@ class Partnership extends CommonObject public $date_partnership_start; public $date_partnership_end; public $count_last_url_check_error; + public $last_check_backlink; public $reason_decline_or_cancel; // END MODULEBUILDER PROPERTIES @@ -188,12 +170,39 @@ class Partnership extends CommonObject $this->db = $db; + $this->fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), + 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), + 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), + 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), + 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>1,), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>$langs->trans('Draft'), '1'=>$langs->trans('Accepted'), '2'=>$langs->trans('Refused'), '9'=>$langs->trans('Canceled')),), + 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), + 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,), + 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), + ); + + if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + $this->fields['fk_member'] = array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1,); + } else { + $this->fields['fk_soc'] = array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1,); + } + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { $this->fields['rowid']['visible'] = 0; } - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { - $this->fields['entity']['enabled'] = 0; - } + // if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + // $this->fields['entity']['enabled'] = 0; + // } // Example to show how to set values of fields definition dynamically /*if ($user->rights->partnership->read) { @@ -229,6 +238,7 @@ class Partnership extends CommonObject */ public function create(User $user, $notrigger = false) { + $this->status = 0; return $this->createCommon($user, $notrigger); } @@ -333,20 +343,97 @@ class Partnership extends CommonObject /** * Load object in memory from the database + * Get object from database. Get also lines. * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id of object to load + * @param string $ref Ref of object + * @param int $fk_soc_or_member fk_soc or fk_member + * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($id, $ref = null) + public function fetch($id, $ref = null, $fk_soc_or_member = null) { - $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); + global $conf; + + // Check parameters + if (empty($id) && empty($ref) && empty($fk_soc_or_member)) { + return -1; + } + + $sql = 'SELECT p.rowid, p.ref, p.fk_soc, p.fk_member, p.status'; + $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation'; + $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif'; + $sql .= ', p.note_private, p.note_public'; + $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel'; + $sql .= ', p.import_key, p.model_pdf'; + + $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p'; + + if ($id) { + $sql .= " WHERE p.rowid=".$id; + } else { + $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Dont't use entity if you use rowid + } + + if ($ref) { + $sql .= " AND p.ref='".$this->db->escape($ref)."'"; + } + + if ($fk_soc_or_member) { + $sql .= ' AND'; + if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') + $sql .= ' p.fk_member = '; + else $sql .= ' p.fk_soc = '; + $sql .= $fk_soc_or_member; + $sql .= ' ORDER BY p.date_partnership_end DESC'; + } + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + if ($obj) { + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->rowid = $obj->rowid; + $this->ref = $obj->ref; + $this->fk_soc = $obj->fk_soc; + $this->fk_member = $obj->fk_member; + $this->status = $obj->status; + $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start); + $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end); + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->fk_user_creat = $obj->fk_user_creat; + $this->tms = $obj->tms; + $this->fk_user_modif = $obj->fk_user_modif; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->last_main_doc = $obj->last_main_doc; + $this->count_last_url_check_error = $obj->count_last_url_check_error; + $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink); + $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel; + $this->import_key = $obj->import_key; + $this->model_pdf = $obj->model_pdf; + + $this->lines = array(); + + // Retrieve all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + + $this->db->free($result); + + return 1; + } else { + // $this->error = 'Partnership with id '.$id.' not found sql='.$sql; + return 0; + } + } else { + $this->error = $this->db->error(); + return -1; } - return $result; } + /** * Load object lines in memory from the database * @@ -765,21 +852,24 @@ class Partnership extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, 0=Nothing done, >0 if OK */ - public function refused($user, $notrigger = '') + public function refused($user, $reasondeclinenote = '', $notrigger = 0) { // Protection - // if ($this->status != self::STATUS_DRAFT) { - // return 0; - // } + if ($this->status == self::STATUS_REFUSED) { + return 0; + } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ + $this->status = self::STATUS_REFUSED; + $this->reason_decline_or_cancel = $reasondeclinenote; - return $this->setStatusCommon($user, self::STATUS_REFUSED, $notrigger, 'PARTNERSHIP_REFUSE'); + $result = $this->update($user); + + if ($result) { + $this->reason_decline_or_cancel = $reasondeclinenote; + return 1; + } + + return -1; } /** @@ -816,7 +906,7 @@ class Partnership extends CommonObject public function reopen($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_CANCELED) { + if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) { return 0; } diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 61659e6075c..992fca2703e 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -26,16 +26,20 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + dol_include_once('partnership/lib/partnership.lib.php'); +dol_include_once('/partnership/class/partnership.class.php'); - +require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; /** * Class with cron tasks of Partnership module */ class PartnershipUtils { public $db; //!< To store db handler - public $error; //!< To return error code (or message) + public $error; //!< To return error code (or message) public $errors=array(); //!< To return several error codes (or messages) @@ -50,33 +54,387 @@ class PartnershipUtils return 1; } - /** - * Action executed by scheduler to cancel status of partnership when subscription is expired + x days. (Max number of cancel per call = $conf->global->PARTNERSHIP_MAX_CANCEL_PER_CALL) + * Action executed by scheduler to cancel status of partnership when subscription is expired + x days. (Max number of action batch per call = $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) * * CAN BE A CRON TASK * * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function doCancelStatusOfPartnership() + public function doCancelStatusOfMemberPartnership() { global $conf, $langs, $user; - $langs->load("agenda"); + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_CANCEL_PER_CALL) ? 100 : $conf->global->PARTNERSHIP_MAX_CANCEL_PER_CALL); // Limit to 100 per call + if ($managedfor != 'member') { + return 0; // If option 'PARTNERSHIP_IS_MANAGED_FOR' = 'thirdparty', this cron job does nothing. + } - $error = 0; - $this->output = ''; - $this->error=''; + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) ? 25 : $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL); // Limit to 25 per call + $langs->loadLangs(array("partnership", "member")); - dol_syslog(__METHOD__." we cancel status of partnership ", LOG_DEBUG); + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); + + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } + + dol_syslog(get_class($this)."::doCancelStatusOfMemberPartnership cancel expired partnerships with grace delay of ".$gracedelay); $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); - // En cours de traitement ... + $this->db->begin(); + + $sql = "SELECT p.rowid, p.fk_member, p.status"; + $sql .= ", d.datefin, d.fk_adherent_type, dty.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = p.fk_member)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; + $sql .= " WHERE fk_member > 0"; + $sql .= " AND (d.datefin < '".$this->db->idate($datetotest)."' AND dty.subscription = 1)"; + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= $this->db->order('d.rowid', 'ASC'); + // Limit is managed into loop later + + $resql = $this->db->query($sql); + if ($resql) { + $numofexpiredmembers = $this->db->num_rows($resql); + + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) { + $ifetchpartner++; + + $obj = $this->db->fetch_object($resql); + if ($obj) { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; + + if ($somethingdoneonpartnership >= $MAXPERCALL) { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING); + break; + } + + $object = new Partnership($this->db); + $object->fetch($obj->rowid); + + // Get expiration date + $expirationdate = $obj->datefin; + + if ($expirationdate && $expirationdate < $now) { // If contract expired (we already had a test into main select, this is a security) + $somethingdoneonpartnership++; + + $result = $object->cancel($user, 0); + // $conf->global->noapachereload = null; + if ($result < 0) { + $error++; + $this->error = $object->error; + if (is_array($object->errors) && count($object->errors)) { + if (is_array($this->errors)) $this->errors = array_merge($this->errors, $object->errors); + else $this->errors = $object->errors; + } + } else { + $partnershipsprocessed[$object->id]=$object->ref; + + // Send an email to inform member + $labeltemplate = '(SendingEmailOnPartnershipCanceled)'; + + dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate); + + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } + + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + + $adherent = new Adherent($this->db); + $adherent->fetch($object->fk_member); + $to = $adherent->email; + + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + } + } + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } + + if (! $error) { + $this->db->commit(); + $this->output = $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } else { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } return ($error ? 1: 0); } + + + /** + * Action executed by scheduler to check if Dolibarr backlink not found on partner website. (Max number of action batch per call = $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) + * + * CAN BE A CRON TASK + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function doWarningOfPartnershipIfDolibarrBacklinkNotfound() + { + global $conf, $langs, $user; + + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call + + $langs->loadLangs(array("partnership", "member")); + + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); + + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } + + $fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc'; + + dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership"); + + $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + + $this->db->begin(); + + $sql = "SELECT p.rowid, p.status, p.".$fk_partner; + $sql .= ", p.last_check_backlink"; + + $sql .= ', partner.url, partner.email'; + + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + + if ($managedfor == 'member') { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as partner on (partner.rowid = p.fk_member)"; + } else { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as partner on (partner.rowid = p.fk_soc)"; + } + + $sql .= " WHERE 1 = 1"; + $sql .= " AND p.".$fk_partner." > 0"; + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. + $sql .= $this->db->order('p.rowid', 'ASC'); + // Limit is managed into loop later + + $resql = $this->db->query($sql); + if ($resql) { + $numofexpiredmembers = $this->db->num_rows($resql); + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) { + $ifetchpartner++; + + $obj = $this->db->fetch_object($resql); + if ($obj) { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; + + if ($somethingdoneonpartnership >= $MAXPERCALL) { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); + break; + } + + $backlinkfound = 0; + + $object = new Partnership($this->db); + $object->fetch($obj->rowid); + + if ($managedfor == 'member') { + $fk_partner = $object->fk_member; + } else { + $fk_partner = $object->fk_soc; + } + + $website = $obj->url; + + if (empty($website)) { + $websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n"; + } else { + $backlinkfound = $this->checkDolibarrBacklink($website); + } + + if (!$backlinkfound) { + $tmpcount = $object->count_last_url_check_error + 1; + + if ($tmpcount > 2 && $tmpcount <= 4) { // Send Warning Email + if (!empty($obj->email)) { + $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; + } else { + $labeltemplate = '(SendingEmailOnPartnershipWillSoonBeCanceled)'; + + dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); + + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } + + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + + $to = $obj->email; + + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + } elseif ($tmpcount > 4) { // Cancel Partnership + $object->status = $object::STATUS_CANCELED; + $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); + } + + $object->count_last_url_check_error = $tmpcount; + } else { + $object->count_last_url_check_error = 0; + $object->reason_decline_or_cancel = ''; + } + + $partnershipsprocessed[$object->id]=$object->ref; + + $object->last_check_backlink = $this->db->idate($now); + + $object->update($user); + } + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } + + if (! $error) { + $this->db->commit(); + $this->output = $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } else { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } + + return ($error ? 1: 0); + } + + /** + * Action to check if Dolibarr backlink not found on partner website + * + * CAN BE A CRON TASK + * @param $website Partner's website + * @return int 0 if KO, 1 if OK + */ + public function checkDolibarrBacklink($website = null) + { + global $conf, $langs, $user; + + $found = 0; + $error = 0; + $webcontent = ''; + + // $website = 'https://nextgestion.com/'; // For Test + $tmpgeturl = getURLContent($website); + if ($tmpgeturl['curl_error_no']) { + $error++; + dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']); + } elseif ($tmpgeturl['http_code'] != '200') { + $error++; + dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']); + } else { + $urlContent = $tmpgeturl['content']; + $dom = new DOMDocument(); + @$dom->loadHTML($urlContent); + + $xpath = new DOMXPath($dom); + $hrefs = $xpath->evaluate("//a"); + + for ($i = 0; $i < $hrefs->length; $i++) { + $href = $hrefs->item($i); + $url = $href->getAttribute('href'); + $url = filter_var($url, FILTER_SANITIZE_URL); + if (!filter_var($url, FILTER_VALIDATE_URL) === false) { + $webcontent .= $url; + } + } + } + + if ($webcontent && !empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) && preg_match('/'.$conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK.'/', $webcontent)) { + $found = 1; + } + + return $found; + } } diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index 5c2b46415b6..b31ced3556f 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -108,9 +108,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') - unset($object->fields['fk_soc']); -else unset($object->fields['fk_member']); + foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha')) { $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -125,21 +123,18 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php -$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; - -// Security check - Protection if external user -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -//if (empty($conf->partnership->enabled)) accessforbidden(); -//if (empty($permissiontoread)) accessforbidden(); +$permissiontoread = $user->rights->partnership->read; +$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; +$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; +if (empty($conf->partnership->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); +if ($object->id > 0 && $object->fk_member > 0 && $managedfor != 'member') accessforbidden(); +if ($object->id > 0 && $object->fk_soc > 0 && $managedfor != 'thirdparty') accessforbidden(); /* * Actions @@ -166,6 +161,19 @@ if (empty($reshook)) { } } + $fk_partner = ($managedfor == 'member') ? GETPOST('fk_member', 'int') : GETPOST('fk_soc', 'int'); + $obj_partner = ($managedfor == 'member') ? $object->fk_member : $object->fk_soc; + + if ($action == 'add' || ($action == 'update' && $obj_partner != $fk_partner)) { + $fpartnership = new Partnership($db); + + $partnershipid = $fpartnership->fetch(0, "", $fk_partner); + if ($partnershipid > 0) { + setEventMessages($langs->trans('PartnershipAlreadyExist').' : '.$fpartnership->getNomUrl(0, '', 1), '', 'errors'); + $action = ($action == 'add') ? 'create' : 'edit'; + } + } + $triggermodname = 'PARTNERSHIP_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen @@ -214,10 +222,12 @@ if (empty($reshook)) { if ($object->statut != $object::STATUS_REFUSED) { $db->begin(); - $result = $object->refused($user, GETPOST('reason_decline_or_cancel', 'alpha')); + $result = $object->refused($user, GETPOST('reason_decline_or_cancel', 'restricthtml')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; + } else { + $object->reason_decline_or_cancel = GETPOST('reason_decline_or_cancel', 'restricthtml'); } if (!$error) { @@ -252,8 +262,14 @@ if (empty($reshook)) { $autocopy = 'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO'; $trackid = 'partnership'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + + if (!empty($id) && !empty(GETPOST('confirm'))) { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } } +if ($object->id > 0 && $object->status == $object::STATUS_REFUSED) $object->fields['reason_decline_or_cancel']['visible'] = 3; @@ -392,7 +408,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'close') { // Create an array for form $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClose'), $langs->trans('ConfirmCloseAsk', $object->ref), 'confirm_close', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClose'), $langs->trans('ConfirmClosePartnershipAsk', $object->ref), 'confirm_close', $formquestion, 'yes', 1); } // Reopon confirmation if ($action == 'reopen') { @@ -405,7 +421,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'refuse') { //Form to close proposal (signed or not) $formquestion = array( - array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel', 'value' => '') // Field to complete private note (not replace) + array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel minwidth400', 'value' => '') // Field to complete private note (not replace) ); // if (!empty($conf->notification->enabled)) { @@ -416,7 +432,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // )); // } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReasonDecline'), $text, 'confirm_refuse', $formquestion, '', 1, 250); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToRefuse'), $text, 'confirm_refuse', $formquestion, '', 1, 250); } // Confirmation of action xxxx @@ -489,6 +505,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }*/ $morehtmlref .= '
'; + if ($managedfor == 'member') $npfilter .= " AND te.fk_member > 0 "; else $npfilter .= " AND te.fk_soc > 0 "; + $object->next_prev_filter = $npfilter; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -504,6 +522,32 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //unset($object->fields['fk_soc']); // Hide field already shown in banner include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + // End of subscription date + if ($managedfor == 'member') { + $fadherent = new Adherent($db); + $fadherent->fetch($object->fk_member); + print ''.$langs->trans("SubscriptionEndDate").''; + if ($fadherent->datefin) { + print dol_print_date($fadherent->datefin, 'day'); + if ($fadherent->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } + } else { + if (!$adht->subscription) { + print $langs->trans("SubscriptionNotRecorded"); + if ($fadherent->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 ($fadherent->statut > 0) { + print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } + } + } + print ''; + } + // Other attributes. Fields from hook formObjectOptions and Extrafields. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; @@ -583,7 +627,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Back to draft - if ($object->status == $object::STATUS_ACCEPTED) { + if ($object->status != $object::STATUS_DRAFT) { print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd); } @@ -600,23 +644,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - // Clone - // print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); - - - // if ($permissiontoadd) { - // if ($object->status == $object::STATUS_ENABLED) { - // print ''.$langs->trans("Disable").''."\n"; - // } else { - // print ''.$langs->trans("Enable").''."\n"; - // } - // } - // Cancel if ($permissiontoadd) { if ($object->status == $object::STATUS_ACCEPTED) { - print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes&token='.newToken(), '', $permissiontoadd); - } elseif ($object->status == $object::STATUS_CANCELED) { + print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); + } elseif ($object->status > $object::STATUS_ACCEPTED) { // print ''.$langs->trans("Re-Open").''."\n"; print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken(), '', $permissiontoadd); } @@ -624,7 +656,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Refuse if ($permissiontoadd) { - if ($object->status != $object::STATUS_CANCELED) { + if ($object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) { print ''.$langs->trans("Refuse").''."\n"; } } @@ -685,7 +717,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Presend form - $modelmail = 'partnership'; + $modelmail = 'partnership_send'; $defaulttopic = 'InformationMessage'; $diroutput = $conf->partnership->dir_output; $trackid = 'partnership'.$object->id; diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index d0a4738576d..1ae90d0d4cf 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -77,6 +77,7 @@ if (!$res) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; // load partnership libraries require_once __DIR__.'/class/partnership.class.php'; @@ -85,7 +86,7 @@ require_once __DIR__.'/class/partnership.class.php'; //dol_include_once('/othermodule/class/otherobject.class.php'); // Load translation files required by the page -$langs->loadLangs(array("partnership", "other")); +$langs->loadLangs(array("partnership", "members", "other")); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) @@ -112,8 +113,9 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object = new Partnership($db); -$extrafields = new ExtraFields($db); +$object = new Partnership($db); +$extrafields = new ExtraFields($db); +$adherent = new Adherent($db); $diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('partnershiplist')); // Note that conf->hooks_modules contains array @@ -123,9 +125,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') - unset($object->fields['fk_soc']); -else unset($object->fields['fk_member']); +$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + +if ($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { @@ -148,6 +150,11 @@ foreach ($object->fields as $key => $val) { $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); } } +$search_filter = GETPOST("search_filter", 'alpha'); +$filter = GETPOST("filter", 'alpha'); +if ($filter) { + $search_filter = $filter; // For backward compatibility +} // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); @@ -178,8 +185,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; +$permissiontoread = $user->rights->partnership->read; +$permissiontoadd = $user->rights->partnership->write; $permissiontodelete = $user->rights->partnership->delete; // Security check @@ -229,6 +236,7 @@ if (empty($reshook)) { } $toselect = ''; $search_array_options = array(); + $search_filter = ""; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { @@ -240,6 +248,38 @@ if (empty($reshook)) { $objectlabel = 'Partnership'; $uploaddir = $conf->partnership->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + // Cancel partnership + if ($massaction == 'cancel' && $permissiontoadd) { + $db->begin(); + + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) { + $result = $objecttmp->cancel($user, 3); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else { + $nbok++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } + } } @@ -263,10 +303,13 @@ $morecss = array(); // -------------------------------------------------------------------- $sql = 'SELECT '; $sql .= $object->getFieldList('t'); +if ($managedfor == 'member') { + $sql .= ', d.datefin, d.fk_adherent_type, dty.subscription'; +} // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } } // Add fields from hooks @@ -278,6 +321,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } +if ($managedfor == 'member') { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; +} // Add table from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -287,6 +334,9 @@ if ($object->ismultientitymanaged == 1) { } else { $sql .= " WHERE 1 = 1"; } +if ($managedfor == 'member') + $sql .= " AND fk_member > 0"; +else $sql .= " AND fk_soc > 0"; foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { if ($key == 'status' && $search[$key] == -1) { @@ -316,6 +366,17 @@ foreach ($search as $key => $val) { } } } +if ($managedfor == 'member') { + if ($search_filter == 'withoutsubscription') { + $sql .= " AND (d.datefin IS NULL OR dty.subscription = 0)"; + } + if ($search_filter == 'uptodate') { + $sql .= " AND (d.datefin >= '".$db->idate($now)."' OR dty.subscription = 0)"; + } + if ($search_filter == 'outofdate') { + $sql .= " AND (d.datefin < '".$db->idate($now)."' AND dty.subscription = 1)"; + } +} if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } @@ -422,6 +483,9 @@ foreach ($search as $key => $val) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +if ($search_filter && $search_filter != '-1') { + $param .= "&search_filter=".urlencode($search_filter); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Add $param from hooks @@ -431,10 +495,10 @@ $param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( - 'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"), - //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), +'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"), + //'generate_doc'=>img_picto('', 'pdf').$langs->trans("ReGeneratePDF"), + //'builddoc'=>img_picto('', 'pdf').$langs->trans("PDFMerge"), + 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendMail"), ); if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); @@ -461,9 +525,9 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort // Add code for pre mass action (confirmation or email presend form) $topicmail = "SendPartnershipRef"; -$modelmail = "partnership"; +$modelmail = "partnership_send"; $objecttmp = new Partnership($db); -$trackid = 'xxxx'.$object->id; +$trackid = 'partnership'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { @@ -500,6 +564,11 @@ print '
'; // You can use div-table-responsive- print ''."\n"; +if ($managedfor == 'member') { + $arrayfields['t.fk_member']['checked'] = 1; +} else { + $arrayfields['t.fk_soc']['checked'] = 1; +} // Fields title search // -------------------------------------------------------------------- print ''; @@ -533,6 +602,13 @@ foreach ($object->fields as $key => $val) { print ''; } } +// End of subscription date +if ($managedfor == 'member') { + print ''; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -566,6 +642,12 @@ foreach ($object->fields as $key => $val) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } +// End of subscription date +if ($managedfor == 'member') { + $key = 'datefin'; + $cssforfield = 'center'; + print getTitleFieldOfList('SubscriptionEndDate', 0, $_SERVER['PHP_SELF'], 'd.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -641,6 +723,31 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } } } + // End of subscription date + if ($managedfor == 'member') { + print ''; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook @@ -665,6 +772,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $i++; } +if ($managedfor != 'member') $totalarray['nbfield']++; // End of subscription date // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; @@ -677,6 +785,7 @@ if ($num == 0) { $colspan++; } } + if ($managedfor != 'member') $colspan++; // End of subscription date print ''; } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index fbbf17628ba..fc89787deda 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -167,9 +167,10 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @param bool $ids_only Return only IDs of product instead of all properties (faster, above all if list is long) * @param int $variant_filter Use this param to filter list (0 = all, 1=products without variants, 2=parent of variants, 3=variants only) + * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0 * @return array Array of product objects */ - public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0) + public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false) { global $db, $conf; @@ -221,6 +222,9 @@ class Products extends DolibarrApi $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } + //this query will return total products with the filters given + $sqlTotals = str_replace('SELECT t.rowid, t.ref, t.ref_ext', 'SELECT count(t.rowid) as total', $sql); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { @@ -254,6 +258,24 @@ class Products extends DolibarrApi if (!count($obj_ret)) { throw new RestException(404, 'No product found'); } + + //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) + if ($pagination_data) { + $totalsResult = $this->db->query($sqlTotals); + $total = $this->db->fetch_object($totalsResult)->total; + + $tmp = $obj_ret; + $obj_ret = []; + + $obj_ret['data'] = $tmp; + $obj_ret['pagination'] = [ + 'total' => (int) $total, + 'page' => $page, //count starts from 0 + 'page_count' => ceil((int) $total/$limit), + 'limit' => $limit + ]; + } + return $obj_ret; } diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index d3f9e6f06bd..70e994d57cd 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -67,8 +67,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +global $dolibarr_main_instance_unique_id; +global $dolibarr_main_url_root; + // Init vars $errmsg = ''; $num = 0; @@ -77,15 +82,15 @@ $backtopage = GETPOST('backtopage', 'alpha'); $action = GETPOST('action', 'aZ09'); $email = GETPOST("email"); +$societe = GETPOST("societe"); // Getting id from Post and decoding it -$encodedid = GETPOST('id'); -$id = dol_decode($encodedid, $dolibarr_main_instance_unique_id); +$id = GETPOST('id'); $conference = new ConferenceOrBooth($db); $resultconf = $conference->fetch($id); if ($resultconf < 0) { - setEventMessages(null, $object->errors, "errors"); + setEventMessages(null, $conference->errors, "errors"); } $project = new Project($db); @@ -95,16 +100,13 @@ if ($resultproject < 0) { $errmsg .= $project->error; } -// Getting 'securekey'.'id' from Post and decoding it -$encodedsecurekeyandid = GETPOST('securekey', 'alpha'); -$securekeyandid = dol_decode($encodedsecurekeyandid, $dolibarr_main_instance_unique_id); -// Securekey decomposition into pure securekey and id added at the end -$securekey = substr($securekeyandid, 0, strlen($securekeyandid)-strlen($encodedid)); -$idgotfromsecurekey = dol_decode(substr($securekeyandid, -strlen($encodedid), strlen($encodedid)), $dolibarr_main_instance_unique_id); +// Security check +$securekeyreceived = GETPOST('securekey', 'alpha'); +$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); -// We check if the securekey collected is OK and if the id collected is the same than the id in the securekey -if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY || $idgotfromsecurekey != $id) { +// We check if the securekey collected is OK +if ($securekeytocompare != $securekeyreceived) { print $langs->trans('MissingOrBadSecureKey'); exit; } @@ -188,6 +190,7 @@ function llxFooterVierge() /* * Actions */ +global $mysoc; $parameters = array(); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); @@ -223,30 +226,72 @@ if (empty($reshook) && $action == 'add') { } if (!$error) { - // Vérifier si client existe par l'email - $thirdparty = new Societe($db); - $resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); + // Check if attendee already exists (by email and for this event) + $confattendee = new ConferenceOrBoothAttendee($db); + $resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$id, 'customsql'=>'t.email="'.$email.'"')); + if ($resultfetchconfattendee > 0 && count($resultfetchconfattendee)>0) { + // Found confattendee + $confattendee = array_shift($resultfetchconfattendee); + } else { + // Need to create a confattendee + $confattendee->date_subscription = dol_now(); + $confattendee->email = $email; + $confattendee->fk_actioncomm = $id; + $resultconfattendee = $confattendee->create($user); + if ($resultconfattendee < 0) { + $error++; + $errmsg .= $confattendee->error; + } + } + // At this point, we have an attendee. It may not be linked to a thirdparty if we just created it + // If the attendee has already paid + if ($confattendee->status == 1) { + $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$id.'&securekey='.$securekeyurl; + Header("Location: ".$redirection); + exit; + } + // Getting the thirdparty or creating it + $thirdparty = new Societe($db); + // Fetch using fk_soc if the attendee was already existing + if (!empty($confattendee->fk_soc)) { + $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc); + } else { + // Fetch using the input field by user if we just created the attendee + if (!empty($societe)) { + $resultfetchthirdparty = $thirdparty->fetch('', $societe); + if ($resultfetchthirdparty<=0) { + // Need to create a new one (not found or multiple with the same name) + $resultfetchthirdparty = 0; + } else { + // We found an unique result with that name, so we put in in fk_soc of attendee + $confattendee->fk_soc = $thirdparty->id; + $confattendee->update($user); + } + } else { + // Need to create a thirdparty (put number>0 if we do not want to create a thirdparty for free-conferences) + $resultfetchthirdparty = 0; + } + } if ($resultfetchthirdparty<0) { $error++; $errmsg .= $thirdparty->error; - $readythirdparty = -1; } elseif ($resultfetchthirdparty==0) { // creation of a new thirdparty - if (!empty(GETPOST("societe"))) { - $thirdparty->name = GETPOST("societe"); + if (!empty($societe)) { + $thirdparty->name = $societe; } else { - $thirdparty->name = $email; + $thirdparty->name = $email; } - - $thirdparty->address = GETPOST("address"); - $thirdparty->zip = GETPOST("zipcode"); - $thirdparty->town = GETPOST("town"); - $thirdparty->client = 2; - $thirdparty->fournisseur = 0; - $thirdparty->country_id = GETPOST("country_id", 'int'); - $thirdparty->state_id = GETPOST("state_id", 'int'); - $thirdparty->email = $email; + $thirdparty->address = GETPOST("address"); + $thirdparty->zip = GETPOST("zipcode"); + $thirdparty->town = GETPOST("town"); + $thirdparty->client = 2; + $thirdparty->fournisseur = 0; + $thirdparty->country_id = GETPOST("country_id", 'int'); + $thirdparty->state_id = GETPOST("state_id", 'int'); + $thirdparty->email = $email; // Load object modCodeTiers $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard'); @@ -267,31 +312,131 @@ if (empty($reshook) && $action == 'add') { } $thirdparty->code_client = $tmpcode; $readythirdparty = $thirdparty->create($user); - } else { - // We have an existing thirdparty ready to use - $readythirdparty = 1; - } - - if ($readythirdparty < 0) { - $error++; - $errmsg .= $thirdparty->error; - } else { - // creation of an attendee - $confattendee = new ConferenceOrBoothAttendee($db); - $confattendee->fk_soc = $thirdparty->id; - $confattendee->date_subscription = dol_now(); - $confattendee->email = GETPOST("email"); - $confattendee->fk_actioncomm = $id; - $resultconfattendee = $confattendee->create($user); - if ($resultconfattendee < 0) { + if ($readythirdparty <0) { $error++; - $errmsg .= $confattendee->error; + $errmsg .= $thirdparty->error; + } else { + $thirdparty->country_code = getCountry($thirdparty->country_id, 2, $db, $langs); + $thirdparty->country = getCountry($thirdparty->country_code, 0, $db, $langs); + $confattendee->fk_soc = $thirdparty->id; + $confattendee->update($user); } } } if (!$error) { $db->commit(); + if (!empty(floatval($project->price_registration))) { + $productforinvoicerow = new Product($db); + $resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION); + if ($resultprod < 0) { + $error++; + $errmsg .= $productforinvoicerow->error; + } else { + $facture = new Facture($db); + $facture->type = Facture::TYPE_STANDARD; + $facture->socid = $thirdparty->id; + $facture->paye = 0; + $facture->date = dol_now(); + $facture->cond_reglement_id = $confattendee->cond_reglement_id; + $facture->fk_project = $project->id; + if (empty($facture->cond_reglement_id)) { + $paymenttermstatic = new PaymentTerm($confattendee->db); + $facture->cond_reglement_id = $paymenttermstatic->getDefaultId(); + if (empty($facture->cond_reglement_id)) { + $error++; + $confattendee->error = 'ErrorNoPaymentTermRECEPFound'; + $confattendee->errors[] = $confattendee->error; + } + } + $resultfacture = $facture->create($user); + if ($resultfacture <= 0) { + $confattendee->error = $facture->error; + $confattendee->errors = $facture->errors; + $error++; + } else { + $facture->add_object_linked($confattendee->element, $confattendee->id); + } + } + + if (!$error) { + // Add line to draft invoice + $vattouse = get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id); + $result = $facture->addline($langs->trans("ConferenceAttendeeFee", $conference->label, dol_print_date($conference->datep, '%d/%m/%y %H:%M:%S'), dol_print_date($conference->datep2, '%d/%m/%y %H:%M:%S')), floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, dol_now(), '', 0, 0, '', 'HT', 0, 1); + if ($result <= 0) { + $confattendee->error = $facture->error; + $confattendee->errors = $facture->errors; + $error++; + } + if (!$error) { + $valid = true; + $sourcetouse = 'conferencesubscription'; + $reftouse = $facture->id; + $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source='.$sourcetouse.'&ref='.$reftouse; + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { + $redirection .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $sourcetouse . $reftouse, 2); // Use the source in the hash to avoid duplicates if the references are identical + } else { + $redirection .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN; + } + } + Header("Location: ".$redirection); + exit; + } + } + } else { + // No price has been set + // Validating the subscription + $confattendee->setStatut(1); + + // Sending mail + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + 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($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + + $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'eventorganization_send', $user, $outputlangs, $labeltouse, 1, ''); + } + + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); + + $sendto = $thirdparty->email; + $from = $conf->global->MAILING_EMAIL_FROM; + $urlback = $_SERVER["REQUEST_URI"]; + + $ishtml = dol_textishtml($texttosend); // May contain urls + + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + + $result = $mailfile->sendfile(); + if ($result) { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } else { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + + $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$id.'&securekey='.$securekeyurl; + Header("Location: ".$redirection); + exit; + } //Header("Location: ".$urlback); //exit; } else { @@ -307,12 +452,6 @@ if (empty($reshook) && $action == 'add') { $form = new Form($db); $formcompany = new FormCompany($db); -$conference = new ConferenceOrBooth($db); -$resultconf = $conference->fetch($id); -if ($resultconf < 0) { - setEventMessages(null, $object->errors, "errors"); -} - llxHeaderVierge($langs->trans("NewSubscription")); @@ -324,12 +463,9 @@ print '
'; print '
'; // Welcome message -print $langs->trans("EvntOrgWelcomeMessage"); -print $id.".".'
'; -print $langs->trans("EvntOrgStartDuration"); -print dol_print_date($conference->datep).' '; -print $langs->trans("EvntOrgEndDuration"); -print ' '.dol_print_date($conference->datef)."."; +print $langs->trans("EvntOrgWelcomeMessage", $conference->label); +print '
'; +print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef)); print '
'; dol_htmloutput_errors($errmsg); @@ -339,8 +475,8 @@ print '
'. print ''; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print '
'; @@ -363,7 +499,7 @@ jQuery(document).ready(function () { print '
'; + $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); + print $form->selectarray('search_filter', $selectarray, $search_filter); + print ''; + $result = $adherent->fetch($object->fk_member); + if ($result) { + $datefin = $adherent->datefin; + if ($datefin) { + print dol_print_date($datefin, 'day'); + if ($adherent->hasDelay()) { + $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; + print " ".img_warning($langs->trans("SubscriptionLate").$textlate); + } + } else { + if ($adherent->subscription == 'yes') { + print $langs->trans("SubscriptionNotReceived"); + if ($adherent->statut > 0) { + print " ".img_warning(); + } + } else { + print ' '; + } + } + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; // Email -print ''."\n"; +print ''."\n"; // Company print ''."\n"; + + // Debitor + print ''."\n"; + + // Object + $text = ''.$langs->trans("PaymentConferenceAttendee").''; + if (GETPOST('desc', 'alpha')) { + $text = ''.$langs->trans(GETPOST('desc', 'alpha')).''; + } + print ''."\n"; + + // Amount + print ''."\n"; + + // Tag + print ''."\n"; + + // Shipping address + $shipToName = $thirdparty->getFullName($langs); + $shipToStreet = $thirdparty->address; + $shipToCity = $thirdparty->town; + $shipToState = $thirdparty->state_code; + $shipToCountryCode = $thirdparty->country_code; + $shipToZip = $thirdparty->zip; + $shipToStreet2 = ''; + $phoneNum = $thirdparty->phone; + if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) { + print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + } else { + print ''."\n"; + } + print ''."\n"; + print ''."\n"; + $labeldesc = $langs->trans("PaymentSubscription"); + if (GETPOST('desc', 'alpha')) { + $labeldesc = GETPOST('desc', 'alpha'); + } + print ''."\n"; +} if (!$found && !$mesg) { $mesg = $langs->trans("ErrorBadParameters"); @@ -1753,7 +1880,7 @@ if ($action != 'dopayment') { print '

'.$langs->trans("DonationPaid").''; } else { // Membership can be paid and we still allow to make renewal - if ($source == 'membersubscription' && $object->datefin > dol_now()) { + if (($source == 'member' || $source == 'membersubscription') && $object->datefin > dol_now()) { $langs->load("members"); print '
'.$langs->trans("MembershipPaid", dol_print_date($object->datefin, 'day')).'
'; print '
'.$langs->trans("PaymentWillBeRecordedForNextPeriod").'
'; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 520a4053000..de9deb7d249 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -51,12 +51,15 @@ if (is_numeric($entity)) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; if (!empty($conf->paypal->enabled)) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; } +global $dolibarr_main_instance_unique_id; + $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal")); // Clean parameters @@ -630,6 +633,26 @@ if ($ispaymentok) { } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + + // Create external user + if (!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN)) { + $infouserlogin = ''; + $nuser = new User($db); + $tmpuser = dol_clone($object); + + $result = $nuser->create_from_member($tmpuser, $object->login); + $newpassword = $nuser->setPassword($user, ''); + + if ($result < 0) { + $outputlangs->load("errors"); + $postactionmessages[] = 'Error in create external user : '.$nuser->error; + } else { + $infouserlogin = $outputlangs->trans("Login").': '.$nuser->login.' '."\n".$outputlangs->trans("Password").': '.$newpassword; + $postactionmessages[] = $langs->trans("NewUserCreated", $nuser->login); + } + $substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin; + } + complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); @@ -892,6 +915,177 @@ if ($ispaymentok) { // TODO send email with acknowledgment for the donation // (need that the donation module can gen a pdf document for the cerfa with pre filled content) + } elseif (array_key_exists('ATT', $tmptag) && $tmptag['ATT'] > 0) { + // Record payment + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $object = new Facture($db); + $result = $object->fetch($ref); + if ($result) { + $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; + + $paymentTypeId = 0; + if ($paymentmethod == 'paybox') { + $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS; + } + if ($paymentmethod == 'paypal') { + $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS; + } + if ($paymentmethod == 'stripe') { + $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; + } + if (empty($paymentTypeId)) { + $paymentType = $_SESSION["paymentType"]; + if (empty($paymentType)) { + $paymentType = 'CB'; + } + $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); + } + + $currencyCodeType = $_SESSION['currencyCodeType']; + + // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) + if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { + $resultvalidate = $object->validate($user); + if ($resultvalidate < 0) { + $postactionmessages[] = 'Cannot validate invoice'; + $ispostactionok = -1; + $error++; // Not yet supported + } else { + $db->begin(); + + // Creation of payment line + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + $paiement = new Paiement($db); + $paiement->datepaye = $now; + if ($currencyCodeType == $conf->currency) { + $paiement->amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id + } else { + $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching + + $postactionmessages[] = 'Payment was done in a different currency that currency expected of company'; + $ispostactionok = -1; + $error++; // Not yet supported + } + $paiement->paiementid = $paymentTypeId; + $paiement->num_payment = ''; + $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress; + $paiement->ext_payment_id = $TRANSACTIONID; + $paiement->ext_payment_site = $service; + + if (!$error) { + $paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents + if ($paiement_id < 0) { + $postactionmessages[] = $paiement->error.' '.join("
\n", $paiement->errors); + $ispostactionok = -1; + $error++; + } else { + $postactionmessages[] = 'Payment created'; + $ispostactionok = 1; + } + } + + if (!$error && !empty($conf->banque->enabled)) { + $bankaccountid = 0; + if ($paymentmethod == 'paybox') { + $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; + } elseif ($paymentmethod == 'paypal') { + $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; + } elseif ($paymentmethod == 'stripe') { + $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; + } + + if ($bankaccountid > 0) { + $label = '(CustomerInvoicePayment)'; + if ($object->type == Facture::TYPE_CREDIT_NOTE) { + $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + } + $result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', ''); + if ($result < 0) { + $postactionmessages[] = $paiement->error.' '.join("
\n", $paiement->errors); + $ispostactionok = -1; + $error++; + } else { + $postactionmessages[] = 'Bank transaction of payment created'; + $ispostactionok = 1; + } + } else { + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.'; + $ispostactionok = -1; + $error++; + } + } + + if (!$error) { + $db->commit(); + + // Validating the attendee + $attendeetovalidate = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendeetovalidate->fetch($tmptag['ATT']); + if ($resultattendee < 0) { + setEventMessages(null, $attendeetovalidate->errors, "errors"); + } else { + $attendeetovalidate->setStatut(1); + + // Sending mail + $thirdparty = new Societe($db); + $thirdparty->fetch($attendeetovalidate->fk_soc); + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + 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($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + + $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'eventorganization_send', $user, $outputlangs, $labeltouse, 1, ''); + } + + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); + + $sendto = $thirdparty->email; + $from = $conf->global->MAILING_EMAIL_FROM; + $urlback = $_SERVER["REQUEST_URI"]; + + $ishtml = dol_textishtml($texttosend); // May contain urls + + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + + $result = $mailfile->sendfile(); + if ($result) { + dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + } else { + dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + } + } + } else { + $db->rollback(); + } + } + } else { + $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of invoice '.$tmptag['ATT'].'. May be payment was already recorded.'; + $ispostactionok = -1; + } + } else { + $postactionmessages[] = 'Invoice paid '.$tmptag['ATT'].' was not found'; + $ispostactionok = -1; + } + } elseif (array_key_exists('BOO', $tmptag) && $tmptag['BOO'] > 0) { + // @todo BOOTH CASE (to copy and adapt from above) } else { // Nothing done } diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php new file mode 100644 index 00000000000..ce48db9e729 --- /dev/null +++ b/htdocs/public/project/index.php @@ -0,0 +1,228 @@ + + * Copyright (C) 2006-2017 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2018 Juanjo Menent + * Copyright (C) 2018-2019 Thibault FOUCART + * Copyright (C) 2021 Waël Almoman + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * For Paypal test: https://developer.paypal.com/ + * For Paybox test: ??? + * For Stripe test: Use credit card 4242424242424242 .More example on https://stripe.com/docs/testing + * + * Variants: + * - When option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is on, we use the new PaymentIntent API + * - When option STRIPE_USE_NEW_CHECKOUT is on, we use the new checkout API + * - If no option set, we use old APIS (charge) + */ + +/** + * \file htdocs/public/payment/newpayment.php + * \ingroup core + * \brief File to offer a way to make a payment for a particular Dolibarr object + */ + +if (!defined('NOLOGIN')) { + define("NOLOGIN", 1); // This means this output page does not require to be logged. +} +if (!defined('NOCSRFCHECK')) { + define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and get of entity must be done before including main.inc.php +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)))); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +// Hook to be used by external payment modules (ie Payzen, ...) +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager = new HookManager($db); +$hookmanager->initHooks(array('newpayment')); + +// For encryption +global $dolibarr_main_instance_unique_id; + +// Load translation files +$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data + +// Security check +// No check on module enabled. Done later according to $validpaymentmethod + +$action = GETPOST('action', 'aZ09'); +$id = GETPOST('id'); +$securekeyreceived = GETPOST("securekey"); +$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + +if ($securekeytocompare != $securekeyreceived) { + print $langs->trans('MissingOrBadSecureKey'); + exit; +} + +// Define $urlwithroot +//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. + +$project = new Project($db); +$resultproject = $project->fetch($id); +if ($resultproject < 0) { + $error++; + $errmsg .= $project->error; +} + +/* + * Actions + */ + + +/* + * View + */ + +$head = ''; +if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) { + $head = ''."\n"; +} + +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; + +$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); + + +// Show sandbox warning +if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled) && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'int'))) { // We can force sand box with param 'forcesandbox' + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Paypal'), '', 'warning'); +} +if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'int'))) { + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); +} + + +print ''."\n"; +print '
'."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print ''; +print "\n"; + + +// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) +// Define logo and logosmall +$logosmall = $mysoc->logo_small; +$logo = $mysoc->logo; +$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; +if (!empty($conf->global->$paramlogo)) { + $logosmall = $conf->global->$paramlogo; +} elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) { + $logosmall = $conf->global->ONLINE_PAYMENT_LOGO; +} +//print ''."\n"; +// Define urllogo +$urllogo = ''; +$urllogofull = ''; +if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); +} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); +} + +// Output html code for logo +if ($urllogo) { + print '
'; + print '
'; + print ''; + print '
'; + if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; + } + print '
'; +} + +print '
'.$langs->trans("Email").' *
'.$langs->trans("Email").'*
'.$langs->trans("Company"); if (!empty(floatval($project->price_registration))) { diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php new file mode 100644 index 00000000000..02fb456f7d2 --- /dev/null +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -0,0 +1,167 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2021 Waël Almoman + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/payment/paymentok.php + * \ingroup core + * \brief File to show page after a successful payment + * This page is called by payment system with url provided to it completed with parameter TOKEN=xxx + * This token can be used to get more informations. + */ + +if (!defined('NOLOGIN')) { + define("NOLOGIN", 1); // This means this output page does not require to be logged. +} +if (!defined('NOCSRFCHECK')) { + define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +$entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + +if (!empty($conf->paypal->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; +} + +global $dolibarr_main_instance_unique_id, $dolibarr_main_url_root, $mysoc; + +$langs->loadLangs(array("main", "companies", "install", "other", "eventorganization")); + +$object = new stdClass(); // For triggers + +$error = 0; + +// Security check +$id = GETPOST("id"); +$securekeyreceived = GETPOST("securekey"); +$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + +if ($securekeyreceived != $securekeytocompare) { + print $langs->trans('MissingOrBadSecureKey'); + exit; +} + +/* + * Actions + */ + + + +/* + * View + */ + +$now = dol_now(); + +dol_syslog("Callback url when a payment was done. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"]) ?dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"]) ?dol_escape_htmltag($_SERVER["SCRIPT_URI"]) : ''), LOG_DEBUG, 0, '_payment'); + +$tracepost = ""; +foreach ($_POST as $k => $v) { + $tracepost .= "{$k} - {$v}\n"; +} +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); + +$head = ''; +if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) { + $head = ''."\n"; +} + +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; + +$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); + + +// Show message +print ''."\n"; +print '
'."\n"; + + +// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) +// Define logo and logosmall +$logosmall = $mysoc->logo_small; +$logo = $mysoc->logo; +$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; +if (!empty($conf->global->$paramlogo)) { + $logosmall = $conf->global->$paramlogo; +} elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) { + $logosmall = $conf->global->ONLINE_PAYMENT_LOGO; +} +//print ''."\n"; +// Define urllogo +$urllogo = ''; +$urllogofull = ''; +if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); +} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); +} + +// Output html code for logo +if ($urllogo) { + print '
'; + print '
'; + print ''; + print '
'; + if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; + } + print '
'; +} + + +print '


'; + +print $langs->trans("SubscriptionOk"); + +print "\n
\n"; + + +htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); + + +// Clean session variables to avoid duplicate actions if post is resent +unset($_SESSION["FinalPaymentAmt"]); +unset($_SESSION["TRANSACTIONID"]); + + +llxFooter('', 'public'); + +$db->close(); diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 7007455791a..287f9a576db 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -59,13 +59,19 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Hook to be used by external payment modules (ie Payzen, ...) include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); $hookmanager->initHooks(array('newpayment')); +// For encryption +global $dolibarr_main_instance_unique_id; + // Load translation files $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data @@ -106,6 +112,38 @@ if (!$action) { } } +if ($source == 'conferencesubscription') { + // Finding the Attendee + $invoiceid = GETPOST('ref'); + $invoice = new Facture($db); + $resultinvoice = $invoice->fetch($invoiceid); + if ($resultinvoice <= 0) { + setEventMessages(null, $invoice->errors, "errors"); + } else { + $invoice->fetchObjectLinked(); + $linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee']; + + if (is_array($linkedAttendees)) { + $linkedAttendees = array_values($linkedAttendees); + + $attendee = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendee->fetch($linkedAttendees[0]); + if ($resultattendee <= 0) { + setEventMessages(null, $attendee->errors, "errors"); + } else { + $amount = price2num($invoice->total_ttc); + // Finding the associated thirdparty + $thirdparty = new Societe($db); + $resultthirdparty = $thirdparty->fetch($invoice->socid); + if ($resultthirdparty <= 0) { + setEventMessages(null, $thirdparty->errors, "errors"); + } + $object = $thirdparty; + } + } + } +} + $paymentmethod = GETPOST('paymentmethod', 'alphanohtml') ?GETPOST('paymentmethod', 'alphanohtml') : ''; // Empty in most cases. Defined when a payment mode is forced $validpaymentmethod = array(); @@ -132,6 +170,7 @@ $ref = $REF = GETPOST('ref', 'alpha'); $TAG = GETPOST("tag", 'alpha'); $FULLTAG = GETPOST("fulltag", 'alpha'); // fulltag is tag with more informations $SECUREKEY = GETPOST("securekey"); // Secure key + if ($paymentmethod && !preg_match('/'.preg_quote('PM='.$paymentmethod, '/').'/', $FULLTAG)) { $FULLTAG .= ($FULLTAG ? '.' : '').'PM='.$paymentmethod; } @@ -1723,6 +1762,94 @@ if ($source == 'donation') { print ''."\n"; } +if ($source == 'conferencesubscription') { + $found = true; + $langs->load("members"); + + if (GETPOST('fulltag', 'alpha')) { + $fulltag = GETPOST('fulltag', 'alpha'); + } else { + $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S'); + if (!empty($TAG)) { + $tag = $TAG; $fulltag .= '.TAG='.$TAG; + } + } + $fulltag = dol_string_unaccent($fulltag); + + // Creditor + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; + print ''; + print '
'.$langs->trans("Attendee"); + print ''; + print $thirdparty->name; + print ''; + print '
'.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''; + print '
'.$langs->trans("Amount"); + print ''; + $valtoshow = $amount; + print ''.price($valtoshow).''; + print ''; + print ''; + + // Currency + print ' '.$langs->trans("Currency".$currency).''; + print ''; + print '
'.$langs->trans("PaymentCode"); + print ''.$fulltag.''; + print ''; + print ''; + print '
'."\n"; + +$text = ''."\n"; +$text .= ''."\n"; +$text .= ''."\n";; + +print $text; + +// Output payment summary form +print ''."\n"; + +print '

'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'
'.$langs->trans("EvntOrgRegistrationHelpMessage").' '.$id.'.

'.$project->note_public.'

'; + +$found = false; +$error = 0; +$var = false; + +$object = null; + +print "\n"; + + +// Show all action buttons +print '
'; +// Output introduction text +if ($project->accept_conference_suggestions) { + print ''; + print '

'; +} +print ''; +print '

'; +if ($project->accept_booth_suggestions) { + print ''; +} + + + +print '
'."\n"; + +print ''."\n"; +print '
'."\n"; +print '
'; + + +htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object); + +llxFooter('', 'public'); + +$db->close(); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 8102c5064f2..3493ccc3f00 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -270,7 +270,8 @@ if (empty($reshook)) { 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', 'Ticket' => '/ticket/class/ticket.class.php', - 'User' => '/user/class/user.class.php' + 'User' => '/user/class/user.class.php', + 'Account' => '/compta/bank/class/account.class.php', ); //First, all core objects must update their tables diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index af9122cba9d..39773b7b637 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -445,7 +445,8 @@ class Thirdparties extends DolibarrApi 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', 'Ticket' => '/ticket/class/ticket.class.php', - 'User' => '/user/class/user.class.php' + 'User' => '/user/class/user.class.php', + 'Account' => '/compta/bank/class/account.class.php' ); //First, all core objects must update their tables diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index e348ec33370..c308ceaef20 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -352,7 +352,7 @@ if (!empty($sql_select)) { $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; } if ($sprod_fulldescr) { - $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; + $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%' OR d.description LIKE '%".$db->escape(dol_htmlentities($sprod_fulldescr))."%'"; if (GETPOST('type_element') != 'fichinter') { $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; } diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php new file mode 100644 index 00000000000..0a5205799a9 --- /dev/null +++ b/htdocs/societe/partnership.php @@ -0,0 +1,552 @@ + + * Copyright (C) 2021 NextGestion + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file partnership_card.php + * \ingroup partnership + * \brief Page to create/edit/view partnership + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +dol_include_once('/partnership/class/partnership.class.php'); +dol_include_once('/partnership/lib/partnership.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("companies","partnership", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +// Security check +$socid = GETPOST('socid', 'int'); +if (!empty($user->socid)) { + $socid = $user->socid; +} + +$societe = new Societe($db); +if ($socid > 0) { + $societe->fetch($socid); +} + +// Initialize technical objects +$object = new Partnership($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('partnershipthirdparty', 'globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); + +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } +} + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +$permissiontoread = $user->rights->partnership->read; +$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php +$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; + + +if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'thirdparty') accessforbidden(); +if (empty($conf->partnership->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); +if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); + +$partnershipid = $object->fetch(0, "", $socid); +if (empty($action) && empty($partnershipid)) { + $action = 'create'; +} +if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT && !empty($user->socid)) accessforbidden(); + +if (empty($socid) && $object) { + $socid = $object->fk_soc; +} +/* + * Actions + */ + +$parameters = array(); +$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'); +} + +$date_start = dol_mktime(0, 0, 0, GETPOST('date_partnership_startmonth', 'int'), GETPOST('date_partnership_startday', 'int'), GETPOST('date_partnership_startyear', 'int')); +$date_end = dol_mktime(0, 0, 0, GETPOST('date_partnership_endmonth', 'int'), GETPOST('date_partnership_endday', 'int'), GETPOST('date_partnership_endyear', 'int')); + +if (empty($reshook)) { + $error = 0; + + $backtopage = dol_buildpath('/partnership/partnership.php', 1).'?socid='.($socid > 0 ? $socid : '__ID__'); + + $triggermodname = 'PARTNERSHIP_MODIFY'; // Name of trigger action code to execute when we modify record + + if ($action == 'add' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $old_start_date = $object->date_partnership_start; + + $object->fk_soc = $socid; + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->date_creation = $now; + $object->fk_user_creat = $user->id; + $object->entity = $conf->entity; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->create($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'create'; + } else { + $db->commit(); + } + } elseif ($action == 'update' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $object->oldcopy = clone $object; + + $old_start_date = $object->date_partnership_start; + + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->fk_user_creat = $user->id; + $object->fk_user_modif = $user->id; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->update($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'edit'; + } else { + $db->commit(); + } + } elseif ($action == 'confirm_close' || $action == 'update_extras') { + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + header("Location: ".$_SERVER['PHP_SELF']."?socid=".$socid); + exit; + } + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; +} + +$object->fields['fk_soc']['visible'] = 0; +if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) $object->fields['reason_decline_or_cancel']['visible'] = 1; +$object->fields['note_public']['visible'] = 1; + +/* + * View + * + * Put here all code to build page + */ + +$form = new Form($db); +$formfile = new FormFile($db); + +$title = $langs->trans("Partnership"); +llxHeader('', $title); + +$form = new Form($db); + +if ($socid) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $langs->load("companies"); + + $societe = new Societe($db); + $result = $societe->fetch($socid); + + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } + $head = societe_prepare_head($societe); + + print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'company'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($societe, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + + print '
'; + + print '
'; + print ''; + + if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field + print ''; + } + + if ($societe->client) { + print ''; + } + + if ($societe->fournisseur) { + print ''; + } + + print '
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; + print $langs->trans('CustomerCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($societe->code_client)); + $tmpcheck = $societe->check_codeclient(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongCustomerCode").')'; + } + print '
'; + print $langs->trans('SupplierCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($societe->code_fournisseur)); + $tmpcheck = $societe->check_codefournisseur(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongSupplierCode").')'; + } + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + $params = ''; + + print '
'; +} else { + dol_print_error('', 'Parameter socid not defined'); +} + +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?socid='.$socid; + + print '
'; + print ''; + print ''; + print ''; + print ''; + + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + print dol_get_fiche_end(); + + print '
'; + print ''; + print '  '; + // print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($partnershipid || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("Partnership"), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?socid='.$socid; + + print '
'; + print ''; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + print load_fiche_titre($langs->trans("PartnershipDedicatedToThisThirdParty", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $res = $object->fetch_optionals(); + + // $head = partnershipPrepareHead($object); + // print dol_get_fiche_head($head, 'card', $langs->trans("Partnership"), -1, $object->picto); + + $linkback = ''; + dol_banner_tab($object, 'id', $linkback, 0, 'rowid', 'ref'); + + $formconfirm = ''; + + // Close confirmation + if ($action == 'close') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClose'), $langs->trans('ConfirmClosePartnershipAsk', $object->ref), 'confirm_close', $formquestion, 'yes', 1); + } + // Reopon confirmation + if ($action == 'reopen') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToReopon'), $langs->trans('ConfirmReoponAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1); + } + + // Refuse confirmatio + if ($action == 'refuse') { + //Form to close proposal (signed or not) + $formquestion = array( + array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel', 'value' => '') // Field to complete private note (not replace) + ); + + // if (!empty($conf->notification->enabled)) { + // require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + // $notify = new Notify($db); + // $formquestion = array_merge($formquestion, array( + // array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)), + // )); + // } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReasonDecline'), $text, 'confirm_refuse', $formquestion, '', 1, 250); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + // Buttons for actions + + if ($action != 'presend') { + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (empty($reshook)) { + if ($object->status == $object::STATUS_DRAFT) { + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$socid.'&action=edit', '', $permissiontoadd); + } + + // Show + if ($permissiontoadd) { + print dolGetButtonAction($langs->trans('ShowPartnership'), '', 'default', dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$object->id, '', $permissiontoadd); + } + + // Cancel + if ($permissiontoadd) { + if ($object->status == $object::STATUS_ACCEPTED) { + print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); + } + } + } + print '
'."\n"; + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index a4fc10c788a..6582ec96172 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -631,7 +631,8 @@ if ($action == "delete") { if ($action == "updateqty") { foreach ($invoice->lines as $line) { if ($line->id == $idline) { - $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + else $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $number, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } @@ -653,7 +654,8 @@ if ($action == "updateprice") { if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { echo $langs->trans("CantBeLessThanMinPrice"); } else { - $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + else $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } } @@ -675,7 +677,8 @@ if ($action == "updatereduction") { if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($line->multicurrency_subprice) * (1 - price2num($number) / 100) < price2num($price_min)))) { echo $langs->trans("CantBeLessThanMinPrice"); } else { - $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + if (!$user->rights->takepos->editlines || (!$user->rights->takepos->editorderedlines && $line->special_code == "4")) dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + else $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index de7fad9f133..2752ee745a1 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3399,7 +3399,7 @@ class User extends CommonObject $sql .= " WHERE t.entity IN (".getEntity('user').")"; } } else { - $sql .= " WHERE 1"; + $sql .= " WHERE 1 = 1"; } // Manage filter