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 ''; + print ''.$langs->trans("Type").''; + print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->fk_type)); + print''; + // Member $adh->ref=$adh->getFullName($langs); print ''; @@ -299,6 +308,18 @@ if ($rowid && $action != 'edit') print '
'; print ''; + + // Type + print ''; + print ''; + print ''; // Member $adh->ref=$adh->getFullName($langs); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index f293ca51184..85c92196a73 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -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 ''; } +// Type +if (! empty($arrayfields['d.fk_type']['checked'])) +{ + print ''; +} + if (! empty($arrayfields['d.lastname']['checked'])) { print ''; @@ -451,6 +471,14 @@ while ($i < min($num, $limit)) print ''; if (! $i) $totalarray['nbfield']++; } + // Type + if (! empty($arrayfields['d.fk_type']['checked'])) + { + 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 ''; - else print ''; + if ($num < $limit) print ''; + else print ''; } 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),
'.$langs->trans("Type").''; + if ( ! empty($object->fk_type) ) { + $adht->fetch($object->fk_type); + print $adht->getNomUrl(1); + } else { + print $langs->trans("NoType"); + } + print '
'; + print ''; + 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 ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1); + print ''.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'