Skip to content

Commit

Permalink
Merge pull request #11847 from ptibogxiv/patch-257
Browse files Browse the repository at this point in the history
NEW: Option to allow to create members from third-party
  • Loading branch information
eldy committed Oct 8, 2019
2 parents 71c18b7 + eba3d96 commit 3acf721
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
13 changes: 13 additions & 0 deletions htdocs/adherents/card.php
Expand Up @@ -866,6 +866,18 @@
$object->country_code=$tmparray['code'];
$object->country=$tmparray['label'];
}

if (!empty($socid)) {
$object = new Societe($db);
if ($socid > 0) $object->fetch($socid);

if (! ($object->id > 0))
{
$langs->load("errors");
print($langs->trans('ErrorRecordNotFound'));
exit;
}
}

$adht = new AdherentType($db);

Expand Down Expand Up @@ -905,6 +917,7 @@ function initfieldrequired()
print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="socid" value="'.$socid.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';

dol_fiche_head('');
Expand Down
1 change: 1 addition & 0 deletions htdocs/adherents/class/adherent.class.php
Expand Up @@ -581,6 +581,7 @@ public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass =
$sql.= ", fk_adherent_type = ".$this->db->escape($this->typeid);
$sql.= ", morphy = '".$this->db->escape($this->morphy)."'";
$sql.= ", birth = ".($this->birth?"'".$this->db->idate($this->birth)."'":"null");
if ($this->socid) $sql.= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party
if ($this->datefin) $sql.= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
if ($this->datevalid) $sql.= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member
$sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest
Expand Down
13 changes: 12 additions & 1 deletion htdocs/societe/card.php
Expand Up @@ -47,7 +47,8 @@
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';

$langs->loadLangs(array("companies","commercial","bills","banks","users"));
$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
if (! empty($conf->adherent->enabled)) $langs->load("members");
if (! empty($conf->categorie->enabled)) $langs->load("categories");
if (! empty($conf->incoterm->enabled)) $langs->load("incoterm");
if (! empty($conf->notification->enabled)) $langs->load("mails");
Expand Down Expand Up @@ -2664,6 +2665,16 @@ function init_supplier_categ() {
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
}

if (! empty($conf->adherent->enabled))
{
$adh = new Adherent($db);
$result=$adh->fetch('', '', $object->id);
if ($result == 0 && ($object->client == 1 || $object->client == 3) && ! empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS))
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/card.php?&action=create&socid='.$object->id.'" title="'.dol_escape_htmltag($langs->trans("NewMember")).'">'.$langs->trans("NewMember").'</a>';
}
}

if ($user->rights->societe->supprimer)
{
Expand Down

0 comments on commit 3acf721

Please sign in to comment.