Merge pull request #10362 from ptibogxiv/patch-87
NEW save and display type of adherent in subscription for more explicit historic
This commit is contained in:
commit
b0b7f53994
@ -55,6 +55,7 @@ class Subscription extends CommonObject
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_type;
|
||||
public $fk_adherent;
|
||||
|
||||
public $amount;
|
||||
@ -102,8 +103,17 @@ class Subscription extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, datec, dateadh, datef, subscription, note)";
|
||||
$sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate($this->datec)."',";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)";
|
||||
|
||||
if ($this->fk_type == null) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
||||
$member=new Adherent($this->db);
|
||||
$result=$member->fetch($this->fk_adherent);
|
||||
$type=$member->typeid;
|
||||
} else {
|
||||
$type=$this->fk_type;
|
||||
}
|
||||
$sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',";
|
||||
$sql.= " '".$this->db->idate($this->dateh)."',";
|
||||
$sql.= " '".$this->db->idate($this->datef)."',";
|
||||
$sql.= " ".$this->amount.",";
|
||||
@ -147,7 +157,7 @@ class Subscription extends CommonObject
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql ="SELECT rowid, fk_adherent, datec,";
|
||||
$sql ="SELECT rowid, fk_type, fk_adherent, datec,";
|
||||
$sql.=" tms,";
|
||||
$sql.=" dateadh as dateh,";
|
||||
$sql.=" datef,";
|
||||
@ -166,6 +176,7 @@ class Subscription extends CommonObject
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
|
||||
$this->fk_type = $obj->fk_type;
|
||||
$this->fk_adherent = $obj->fk_adherent;
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->datem = $this->db->jdate($obj->tms);
|
||||
@ -203,6 +214,7 @@ class Subscription extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET ";
|
||||
$sql .= " fk_type = ".$this->fk_type.",";
|
||||
$sql .= " fk_adherent = ".$this->fk_adherent.",";
|
||||
$sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').",";
|
||||
$sql .= " subscription = '".price2num($this->amount)."',";
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
||||
if (! empty($conf->banque->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
@ -34,6 +35,7 @@ if (! empty($conf->banque->enabled)) {
|
||||
$langs->loadLangs(array("companies","members","bills","users"));
|
||||
|
||||
$adh = new Adherent($db);
|
||||
$adht = new AdherentType($db);
|
||||
$object = new Subscription($db);
|
||||
$errmsg='';
|
||||
|
||||
@ -102,6 +104,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && ! $canc
|
||||
// Modifie valeures
|
||||
$object->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
|
||||
$object->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']);
|
||||
$object->fk_type=$_POST["typeid"];
|
||||
$object->note=$_POST["note"];
|
||||
$object->amount=$_POST["amount"];
|
||||
//print 'datef='.$object->datef.' '.$_POST['datesubendday'];
|
||||
@ -202,6 +205,12 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
|
||||
print $form->showrefnav($object, 'rowid', $linkback, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Type
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Type").'</td><td class="valeur" colspan="3">';
|
||||
print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type));
|
||||
print'</td></tr>';
|
||||
|
||||
// Member
|
||||
$adh->ref=$adh->getFullName($langs);
|
||||
print '<tr>';
|
||||
@ -299,6 +308,18 @@ if ($rowid && $action != 'edit')
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Type
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans("Type").'</td>';
|
||||
print '<td class="valeur">';
|
||||
if ( ! empty($object->fk_type) ) {
|
||||
$adht->fetch($object->fk_type);
|
||||
print $adht->getNomUrl(1);
|
||||
} else {
|
||||
print $langs->trans("NoType");
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Member
|
||||
$adh->ref=$adh->getFullName($langs);
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
@ -38,6 +39,7 @@ $toselect = GETPOST('toselect', 'array');
|
||||
$filter=GETPOST("filter","alpha");
|
||||
$statut=(GETPOSTISSET("statut")?GETPOST("statut","alpha"):1);
|
||||
$search_ref=GETPOST('search_ref','alpha');
|
||||
$search_type=GETPOST('search_type','alpha');
|
||||
$search_lastname=GETPOST('search_lastname','alpha');
|
||||
$search_firstname=GETPOST('search_firstname','alpha');
|
||||
$search_login=GETPOST('search_login','alpha');
|
||||
@ -74,6 +76,7 @@ $fieldstosearchall = array(
|
||||
);
|
||||
$arrayfields=array(
|
||||
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
||||
'd.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
|
||||
'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
|
||||
'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1),
|
||||
'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
|
||||
@ -112,16 +115,17 @@ if (empty($reshook))
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
$search="";
|
||||
$search_ref="";
|
||||
$search_lastname="";
|
||||
$search_firstname="";
|
||||
$search_login="";
|
||||
$search_note="";
|
||||
$search_amount="";
|
||||
$search_account="";
|
||||
$toselect='';
|
||||
$search_array_options=array();
|
||||
$search="";
|
||||
$search_type="";
|
||||
$search_ref="";
|
||||
$search_lastname="";
|
||||
$search_firstname="";
|
||||
$search_login="";
|
||||
$search_note="";
|
||||
$search_amount="";
|
||||
$search_account="";
|
||||
$toselect='';
|
||||
$search_array_options=array();
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +143,7 @@ $now=dol_now();
|
||||
|
||||
// List of subscriptions
|
||||
$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo,";
|
||||
$sql.= " c.rowid as crowid, c.subscription,";
|
||||
$sql.= " c.rowid as crowid, c.fk_type, c.subscription,";
|
||||
$sql.= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,";
|
||||
$sql.= " c.fk_bank as bank, c.note,";
|
||||
$sql.= " b.fk_account";
|
||||
@ -157,6 +161,7 @@ if ($search_ref)
|
||||
if (is_numeric($search_ref)) $sql.= " AND (c.rowid = ".$db->escape($search_ref).")";
|
||||
else $sql.=" AND 1 = 2"; // Always wrong
|
||||
}
|
||||
if ($search_type) $sql.= natural_search(array('c.fk_type'), $search_type);
|
||||
if ($search_lastname) $sql.= natural_search(array('d.lastname','d.societe'), $search_lastname);
|
||||
if ($search_firstname) $sql.= natural_search(array('d.firstname'), $search_firstname);
|
||||
if ($search_login) $sql.= natural_search('d.login', $search_login);
|
||||
@ -220,6 +225,7 @@ $param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
|
||||
if ($statut != '') $param.="&statut=".urlencode($statut);
|
||||
if ($search_type) $param.="&search_type=".urlencode($search_type);
|
||||
if ($date_select) $param.="&date_select=".urlencode($date_select);
|
||||
if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname);
|
||||
if ($search_login) $param.="&search_login=".urlencode($search_login);
|
||||
@ -297,6 +303,14 @@ if (! empty($arrayfields['d.ref']['checked']))
|
||||
print '<input class="flat" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="4"></td>';
|
||||
}
|
||||
|
||||
// Type
|
||||
if (! empty($arrayfields['d.fk_type']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" align="left">';
|
||||
print '<input class="flat" type="text" name="search_type" value="'.dol_escape_htmltag($search_type).'" size="7">';
|
||||
print'</td>';
|
||||
}
|
||||
|
||||
if (! empty($arrayfields['d.lastname']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre" align="left">';
|
||||
@ -379,6 +393,10 @@ if (! empty($arrayfields['d.ref']['checked']))
|
||||
{
|
||||
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"c.rowid",$param,"","",$sortfield,$sortorder);
|
||||
}
|
||||
if (! empty($arrayfields['d.fk_type']['checked']))
|
||||
{
|
||||
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"c.fk_type",$param,"","",$sortfield,$sortorder);
|
||||
}
|
||||
if (! empty($arrayfields['d.lastname']['checked']))
|
||||
{
|
||||
print_liste_field_titre("LastName",$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
|
||||
@ -441,7 +459,9 @@ while ($i < min($num, $limit))
|
||||
$adherent->statut=$obj->statut;
|
||||
$adherent->login=$obj->login;
|
||||
$adherent->photo=$obj->photo;
|
||||
|
||||
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($obj->fk_type);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
@ -451,6 +471,14 @@ while ($i < min($num, $limit))
|
||||
print '<td>'.$subscription->getNomUrl(1).'</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Type
|
||||
if (! empty($arrayfields['d.fk_type']['checked']))
|
||||
{
|
||||
print '<td>';
|
||||
if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1);
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Lastname
|
||||
if (! empty($arrayfields['d.lastname']['checked']))
|
||||
@ -568,8 +596,8 @@ if (isset($totalarray['pos']))
|
||||
{
|
||||
if ($i == 1)
|
||||
{
|
||||
if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>';
|
||||
else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||
}
|
||||
else print '<td></td>';
|
||||
}
|
||||
|
||||
@ -80,6 +80,7 @@ create table llx_mailing_unsubscribe
|
||||
ALTER TABLE llx_mailing_unsubscribe ADD UNIQUE uk_mailing_unsubscribe(email, entity, unsubscribegroup);
|
||||
|
||||
ALTER TABLE llx_adherent ADD gender VARCHAR(10);
|
||||
ALTER TABLE llx_subscription ADD fk_type integer(11);
|
||||
|
||||
-- Add url_id into unique index of bank_url
|
||||
ALTER TABLE llx_bank_url DROP INDEX uk_bank_url;
|
||||
|
||||
@ -22,6 +22,7 @@ create table llx_subscription
|
||||
tms timestamp,
|
||||
datec datetime,
|
||||
fk_adherent integer,
|
||||
fk_type integer,
|
||||
dateadh datetime,
|
||||
datef date,
|
||||
subscription double(24,8),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user