diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 784f6d4dea762f8c3a0f07dfde8b817c2b2edb58..dcc8b671259b59ed130ab181dad0171a81f75360 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 6b980a4df1cec555d991a01e7c148054d423d7ce..28fb2268d4c9aecb28d610f79b13f9dd5e2d1127 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']; - - $result=$subscription->update($user); - if ($result >= 0 && ! count($subscription->errors)) + $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=$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.='<br>'; $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 '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print "<input type=\"hidden\" name=\"action\" value=\"update\">"; print "<input type=\"hidden\" name=\"rowid\" value=\"$rowid\">"; - print "<input type=\"hidden\" name=\"fk_bank\" value=\"".$subscription->fk_bank."\">"; + print "<input type=\"hidden\" name=\"fk_bank\" value=\"".$object->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 '<tr><td width="20%">'.$langs->trans("Ref").'</td>'; print '<td class="valeur" colspan="3">'; - print $form->showrefnav($subscription, 'rowid', $linkback, 1); + print $form->showrefnav($object, 'rowid', $linkback, 1); print '</td></tr>'; // Member @@ -207,34 +222,34 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') // Date start subscription print '<tr><td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="2">'; - $form->select_date($subscription->dateh,'datesub',1,1,0,'update',1); + $form->select_date($object->dateh,'datesub',1,1,0,'update',1); print '</td>'; print '</tr>'; // Date end subscription print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td class="valeur" colspan="2">'; - $form->select_date($subscription->datef,'datesubend',0,0,0,'update',1); + $form->select_date($object->datef,'datesubend',0,0,0,'update',1); print '</td>'; print '</tr>'; // Amount print '<tr><td>'.$langs->trans("Amount").'</td><td class="valeur" colspan="2">'; - print '<input type="text" class="flat" size="10" name="amount" value="'.price($subscription->amount).'"></td></tr>'; + print '<input type="text" class="flat" size="10" name="amount" value="'.price($object->amount).'"></td></tr>'; // Label print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur" colspan="2">'; - print '<input type="text" class="flat" size="60" name="note" value="'.$subscription->note.'"></td></tr>'; + print '<input type="text" class="flat" size="60" name="note" value="'.$object->note.'"></td></tr>'; // 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 '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="2">'; - 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']='<b>'.$langs->trans("ThisWillAlsoDeleteBankRecord").'</b>'; $text=$langs->trans("ConfirmDeleteSubscription"); if (! empty($conf->banque->enabled) && ! empty($conf->global->ADHERENT_BANK_USE)) $text.='<br>'.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 '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; @@ -307,7 +322,7 @@ if ($rowid && $action != 'edit') // Ref print '<tr><td width="20%">'.$langs->trans("Ref").'</td>'; print '<td class="valeur" colspan="3">'; - print $form->showrefnav($subscription, 'rowid', $linkback, 1); + print $form->showrefnav($object, 'rowid', $linkback, 1); print '</td></tr>'; // Member @@ -318,35 +333,35 @@ if ($rowid && $action != 'edit') // Date record /*print '<tr>'; - print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="3">'.dol_print_date($subscription->datec,'dayhour').'</td>'; + print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="3">'.dol_print_date($object->datec,'dayhour').'</td>'; print '</tr>';*/ // Date subscription print '<tr>'; - print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="3">'.dol_print_date($subscription->dateh,'day').'</td>'; + print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="3">'.dol_print_date($object->dateh,'day').'</td>'; print '</tr>'; // Date end subscription print '<tr>'; - print '<td>'.$langs->trans("DateEndSubscription").'</td><td class="valeur" colspan="3">'.dol_print_date($subscription->datef,'day').'</td>'; + print '<td>'.$langs->trans("DateEndSubscription").'</td><td class="valeur" colspan="3">'.dol_print_date($object->datef,'day').'</td>'; print '</tr>'; // Amount - print '<tr><td>'.$langs->trans("Amount").'</td><td class="valeur" colspan="3">'.price($subscription->amount).'</td></tr>'; + print '<tr><td>'.$langs->trans("Amount").'</td><td class="valeur" colspan="3">'.price($object->amount).'</td></tr>'; // Amount - print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur" colspan="3">'.$subscription->note.'</td></tr>'; + print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur" colspan="3">'.$object->note.'</td></tr>'; // 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 '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="3">'; - 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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?rowid=".$subscription->id."&action=edit\">".$langs->trans("Modify")."</a></div>"; + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id."&action=edit\">".$langs->trans("Modify")."</a></div>"; } else { @@ -384,12 +399,49 @@ if ($rowid && $action != 'edit') // Supprimer if ($user->rights->adherent->cotisation->creer) { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"]."?rowid=".$subscription->id."&action=delete\">".$langs->trans("Delete")."</a></div>\n"; + print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"]."?rowid=".$object->id."&action=delete\">".$langs->trans("Delete")."</a></div>\n"; } print '</div>'; - print "<br>\n"; - + + + print '<div class="fichecenter"><div class="fichehalfleft">'; + print '<a name="builddoc"></a>'; // 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 '<br>'.$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 '</div><div class="fichehalfright"><div class="ficheaddleft">'; + + // 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 '</div></div></div>'; } diff --git a/htdocs/adherents/tpl/index.html b/htdocs/adherents/tpl/index.html new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php new file mode 100644 index 0000000000000000000000000000000000000000..f593e72faa925e595706da0735462720a0f0063c --- /dev/null +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -0,0 +1,55 @@ +<?php +/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2014 Marcos GarcĂa <marcosgdf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + * + */ +?> + +<!-- BEGIN PHP TEMPLATE --> + +<?php + +global $user; + +$langs = $GLOBALS['langs']; +$linkedObjectBlock = $GLOBALS['linkedObjectBlock']; +$langs->load("members"); + +$var=true; +$total=0; +foreach($linkedObjectBlock as $key => $objectlink) +{ + $var=!$var; +?> +<tr <?php echo $GLOBALS['bc'][$var]; ?> > + <td><?php echo $langs->trans("Subscription"); ?></td> + <td><?php echo $objectlink->getNomUrl(1); ?></td> + <td align="center"></td> + <td align="center"><?php echo dol_print_date($objectlink->dateh,'day'); ?></td> + <td align="right"><?php + if ($user->rights->adherent->lire) { + $total = $total + $objectlink->amount; + echo price($objectlink->amount); + } ?></td> + <td align="right"></td> + <td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td> +</tr> +<?php +} +?> + +<!-- END PHP TEMPLATE --> \ No newline at end of file diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 15272a19d6cdfd76c7a3f8dfefa187360569c21d..83499a85b3a467205253636df9ffd99aea224571 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 b3643fa4f53757a6736881c42377aa631cdfed12..d4267eccfb1ac6cd161d529f92da9c0290f5d568 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 '<br>'; + print '<br>'; print load_fiche_titre($langs->trans('RelatedObjects'), '', ''); print '<table class="noborder allwidth">';