diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 29f1f94e683..96876eb82b6 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -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)."',"; diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index c951f36db6e..014806a2a2f 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -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 ''; + // Type + print '
| '.$langs->trans("Type").' | '; + print ''; + if ( ! empty($object->fk_type) ) { + $adht->fetch($object->fk_type); + print $adht->getNomUrl(1); + } else { + print $langs->trans("NoType"); + } + print ' | '; + print ''; + print' | '; +} + if (! empty($arrayfields['d.lastname']['checked'])) { print ''; @@ -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 ' | |||
| '.$subscription->getNomUrl(1).' | '; if (! $i) $totalarray['nbfield']++; } + // Type + if (! empty($arrayfields['d.fk_type']['checked'])) + { + print ''; + if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1); + print ' | '; + 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 ''.$langs->trans("Total").' | '; - else print ''.$langs->trans("Totalforthispage").' | '; + if ($num < $limit) print ''.$langs->trans("Total").' | '; + else print ''.$langs->trans("Totalforthispage").' | '; } else print ''; } diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 0079e90f2ae..385e13b1905 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -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; diff --git a/htdocs/install/mysql/tables/llx_subscription.sql b/htdocs/install/mysql/tables/llx_subscription.sql index 8d220ed9059..cb53d9405e9 100644 --- a/htdocs/install/mysql/tables/llx_subscription.sql +++ b/htdocs/install/mysql/tables/llx_subscription.sql @@ -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), |