diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 784f6d4dea7..dcc8b671259 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -53,6 +53,10 @@ $result=restrictedArea($user,'adherent',$rowid,'','cotisation'); $object = new Adherent($db); $extrafields = new ExtraFields($db); $adht = new AdherentType($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + $errmsg=''; $errmsgs=array(); @@ -379,6 +383,13 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $ $invoice->socid=$object->fk_soc; $invoice->date=$datecotisation; + // Possibility to add external linked objects with hooks + $invoice->linked_objects['subscription'] = $crowid; + if (! empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects'])) + { + $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']); + } + $result=$invoice->create($user); if ($result <= 0) { diff --git a/htdocs/adherents/fiche_subscription.php b/htdocs/adherents/fiche_subscription.php index 6b980a4df1c..28fb2268d4c 100644 --- a/htdocs/adherents/fiche_subscription.php +++ b/htdocs/adherents/fiche_subscription.php @@ -33,35 +33,49 @@ $langs->load("members"); $langs->load("users"); $adh = new Adherent($db); -$subscription = new Cotisation($db); +$object = new Cotisation($db); $errmsg=''; -$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; -$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; -$typeid=isset($_GET["typeid"])?$_GET["typeid"]:$_POST["typeid"]; +$action=GETPOST("action",'alpha'); +$rowid=GETPOST("rowid","int")?GETPOST("rowid","int"):GETPOST("id","int"); +$typeid=GETPOST("typeid","int"); +$cancel=GETPOST('cancel'); if (! $user->rights->adherent->cotisation->lire) accessforbidden(); +$permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php + /* * Actions */ +if ($cancel) $action=''; + +//include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + +include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + +//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update' && ! $_POST["cancel"]) { // Charge objet actuel - $result=$subscription->fetch($_POST["rowid"]); + $result=$object->fetch($_POST["rowid"]); if ($result > 0) { $db->begin(); $errmsg=''; - if ($subscription->fk_bank) + if ($object->fk_bank) { $accountline=new AccountLine($db); - $result=$accountline->fetch($subscription->fk_bank); + $result=$accountline->fetch($object->fk_bank); // If transaction consolidated if ($accountline->rappro) @@ -84,31 +98,31 @@ if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update if (! $errmsg) { // Modifie valeures - $subscription->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); - $subscription->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']); - $subscription->note=$_POST["note"]; - $subscription->amount=$_POST["amount"]; - //print 'datef='.$subscription->datef.' '.$_POST['datesubendday']; + $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->note=$_POST["note"]; + $object->amount=$_POST["amount"]; + //print 'datef='.$object->datef.' '.$_POST['datesubendday']; - $result=$subscription->update($user); - if ($result >= 0 && ! count($subscription->errors)) + $result=$object->update($user); + if ($result >= 0 && ! count($object->errors)) { $db->commit(); - header("Location: fiche_subscription.php?rowid=".$subscription->id); + header("Location: fiche_subscription.php?rowid=".$object->id); exit; } else { $db->rollback(); - if ($subscription->error) + if ($object->error) { - $errmsg=$subscription->error; + $errmsg=$object->error; } else { - foreach($subscription->errors as $error) + foreach($object->errors as $error) { if ($errmsg) $errmsg.='
'; $errmsg.=$error; @@ -126,11 +140,11 @@ if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->adherent->cotisation->creer) { - $result=$subscription->fetch($rowid); - $result=$subscription->delete($user); + $result=$object->fetch($rowid); + $result=$object->delete($user); if ($result > 0) { - header("Location: card_subscriptions.php?rowid=".$subscription->fk_adherent); + header("Location: card_subscriptions.php?rowid=".$object->fk_adherent); exit; } else @@ -145,11 +159,12 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && * View */ -llxHeader('',$langs->trans("SubscriptionCard"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); - $form = new Form($db); +llxHeader('',$langs->trans("SubscriptionCard"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); + + dol_htmloutput_errors($errmsg); @@ -161,8 +176,8 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') * ********************************************/ - $subscription->fetch($rowid); - $result=$adh->fetch($subscription->fk_adherent); + $object->fetch($rowid); + $result=$adh->fetch($object->fk_adherent); /* * Affichage onglets @@ -170,12 +185,12 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$subscription->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$object->id; $head[$h][1] = $langs->trans("SubscriptionCard"); $head[$h][2] = 'general'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/info_subscription.php?rowid='.$subscription->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/info_subscription.php?rowid='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -184,7 +199,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') print ''; print ""; print ""; - print "fk_bank."\">"; + print "fk_bank."\">"; dol_fiche_head($head, 'general', $langs->trans("Subscription"), 0, 'payment'); @@ -196,7 +211,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') // Ref print ''.$langs->trans("Ref").''; print ''; - print $form->showrefnav($subscription, 'rowid', $linkback, 1); + print $form->showrefnav($object, 'rowid', $linkback, 1); print ''; // Member @@ -207,34 +222,34 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') // Date start subscription print ''.$langs->trans("DateSubscription").''; - $form->select_date($subscription->dateh,'datesub',1,1,0,'update',1); + $form->select_date($object->dateh,'datesub',1,1,0,'update',1); print ''; print ''; // Date end subscription print ''.$langs->trans("DateEndSubscription").''; - $form->select_date($subscription->datef,'datesubend',0,0,0,'update',1); + $form->select_date($object->datef,'datesubend',0,0,0,'update',1); print ''; print ''; // Amount print ''.$langs->trans("Amount").''; - print ''; + print ''; // Label print ''.$langs->trans("Label").''; - print ''; + print ''; // Bank line if (! empty($conf->banque->enabled)) { - if ($conf->global->ADHERENT_BANK_USE || $subscription->fk_bank) + if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { print ''.$langs->trans("BankTransactionLine").''; - if ($subscription->fk_bank) + if ($object->fk_bank) { $bankline=new AccountLine($db); - $result=$bankline->fetch($subscription->fk_bank); + $result=$bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1,0,'showall'); } else @@ -267,8 +282,8 @@ if ($rowid && $action != 'edit') /* */ /* ************************************************************************** */ - $result=$subscription->fetch($rowid); - $result=$adh->fetch($subscription->fk_adherent); + $result=$object->fetch($rowid); + $result=$adh->fetch($object->fk_adherent); /* * Affichage onglets @@ -276,12 +291,12 @@ if ($rowid && $action != 'edit') $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$subscription->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$object->id; $head[$h][1] = $langs->trans("SubscriptionCard"); $head[$h][2] = 'general'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/adherents/info_subscription.php?rowid='.$subscription->id; + $head[$h][0] = DOL_URL_ROOT.'/adherents/info_subscription.php?rowid='.$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; @@ -295,7 +310,7 @@ if ($rowid && $action != 'edit') //$formquestion['text']=''.$langs->trans("ThisWillAlsoDeleteBankRecord").''; $text=$langs->trans("ConfirmDeleteSubscription"); if (! empty($conf->banque->enabled) && ! empty($conf->global->ADHERENT_BANK_USE)) $text.='
'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord"); - print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$subscription->id,$langs->trans("DeleteSubscription"),$text,"confirm_delete",$formquestion,0,1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("DeleteSubscription"),$text,"confirm_delete",$formquestion,0,1); } print '
'; @@ -307,7 +322,7 @@ if ($rowid && $action != 'edit') // Ref print ''.$langs->trans("Ref").''; print ''; - print $form->showrefnav($subscription, 'rowid', $linkback, 1); + print $form->showrefnav($object, 'rowid', $linkback, 1); print ''; // Member @@ -318,35 +333,35 @@ if ($rowid && $action != 'edit') // Date record /*print ''; - print ''.$langs->trans("DateSubscription").''.dol_print_date($subscription->datec,'dayhour').''; + print ''.$langs->trans("DateSubscription").''.dol_print_date($object->datec,'dayhour').''; print '';*/ // Date subscription print ''; - print ''.$langs->trans("DateSubscription").''.dol_print_date($subscription->dateh,'day').''; + print ''.$langs->trans("DateSubscription").''.dol_print_date($object->dateh,'day').''; print ''; // Date end subscription print ''; - print ''.$langs->trans("DateEndSubscription").''.dol_print_date($subscription->datef,'day').''; + print ''.$langs->trans("DateEndSubscription").''.dol_print_date($object->datef,'day').''; print ''; // Amount - print ''.$langs->trans("Amount").''.price($subscription->amount).''; + print ''.$langs->trans("Amount").''.price($object->amount).''; // Amount - print ''.$langs->trans("Label").''.$subscription->note.''; + print ''.$langs->trans("Label").''.$object->note.''; // Bank line if (! empty($conf->banque->enabled)) { - if ($conf->global->ADHERENT_BANK_USE || $subscription->fk_bank) + if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { print ''.$langs->trans("BankTransactionLine").''; - if ($subscription->fk_bank) + if ($object->fk_bank) { $bankline=new AccountLine($db); - $result=$bankline->fetch($subscription->fk_bank); + $result=$bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1,0,'showall'); } else @@ -373,7 +388,7 @@ if ($rowid && $action != 'edit') { if (! $bankline->rappro) { - print '
".$langs->trans("Modify")."
"; + print '
".$langs->trans("Modify")."
"; } else { @@ -384,12 +399,49 @@ if ($rowid && $action != 'edit') // Supprimer if ($user->rights->adherent->cotisation->creer) { - print '
".$langs->trans("Delete")."
\n"; + print '
".$langs->trans("Delete")."
\n"; } print ''; - print "
\n"; - + + + print '
'; + print ''; // ancre + + // Documents generes + /* + $filename = dol_sanitizeFileName($object->ref); + $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id; + $genallowed = $user->rights->facture->creer; + $delallowed = $user->rights->facture->supprimer; + + print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + $somethingshown = $formfile->numoffiles; + */ + // Linked object block + $somethingshown = $form->showLinkedObjectBlock($object); + + // Show links to link elements + /*$linktoelem = $form->showLinkToObjectBlock($object,array('order')); + if ($linktoelem) print '
'.$linktoelem; + + // Link for paypal payment + if (! empty($conf->paypal->enabled) && $object->statut != 0) { + include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; + print showPaypalPaymentUrl('invoice', $object->ref); + } + */ + print '
'; + + // List of actions on element + /* + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'invoice', $socid); + */ + + print '
'; } diff --git a/htdocs/adherents/tpl/index.html b/htdocs/adherents/tpl/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php new file mode 100644 index 00000000000..f593e72faa9 --- /dev/null +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -0,0 +1,55 @@ + + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2014 Marcos GarcĂ­a + * + * 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 . + * + */ +?> + + + +load("members"); + +$var=true; +$total=0; +foreach($linkedObjectBlock as $key => $objectlink) +{ + $var=!$var; +?> + > + trans("Subscription"); ?> + getNomUrl(1); ?> + + dateh,'day'); ?> + rights->adherent->lire) { + $total = $total + $objectlink->amount; + echo price($objectlink->amount); + } ?> + + ">transnoentitiesnoconv("RemoveLink")); ?> + + + + \ No newline at end of file diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 15272a19d6c..83499a85b3a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2541,12 +2541,10 @@ abstract class CommonObject else if ($objecttype == 'fichinter') { $classpath = 'fichinter/class'; $subelement = 'fichinter'; $module = 'ficheinter'; } - - // TODO ajout temporaire - MAXIME MANGIN - else if ($objecttype == 'contratabonnement') { - $classpath = 'contrat/class'; $subelement = 'contrat'; $module = 'contratabonnement'; + else if ($objecttype == 'subscription') { + $classpath = 'adherents/class'; $module = 'adherent'; } - + // Set classfile $classfile = strtolower($subelement); $classname = ucfirst($subelement); @@ -2562,6 +2560,9 @@ abstract class CommonObject else if ($objecttype == 'facturerec') { $classfile = 'facture-rec'; $classname = 'FactureRec'; } + else if ($objecttype == 'subscription') { + $classfile = 'cotisation'; $classname = 'Cotisation'; + } // Here $module, $classfile and $classname are set if ($conf->$module->enabled && (($element != $this->element) || $alsosametype)) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b3643fa4f53..d4267eccfb1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5170,7 +5170,7 @@ class Form { $num = count($object->linkedObjects); $numoutput=0; - + foreach($object->linkedObjects as $objecttype => $objects) { $tplpath = $element = $subelement = $objecttype; @@ -5217,7 +5217,10 @@ class Form else if ($objecttype == 'expensereport') { $tplpath = 'expensereport'; } - + else if ($objecttype == 'subscription') { + $tplpath = 'adherents'; + } + global $linkedObjectBlock; $linkedObjectBlock = $objects; @@ -5225,7 +5228,7 @@ class Form { $numoutput++; - echo '
'; + print '
'; print load_fiche_titre($langs->trans('RelatedObjects'), '', ''); print '';