*
* PHP version 5
*
- * Copyright © 2020 The Galette Team
+ * Copyright © 2020-2021 The Galette Team
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020 The Galette Team
+ * @copyright 2020-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.9.4dev - 2020-05-08
* @name ContributionsController
* @package Galette
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020 The Galette Team
+ * @copyright 2020-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.9.4dev - 2020-05-02
}
}
+ if (count($error_detected) === 0) {
+ $files_res = $contrib->handleFiles($_FILES);
+ if (is_array($files_res)) {
+ $error_detected = array_merge($error_detected, $files_res);
+ }
+ }
+
if (count($error_detected) == 0) {
$this->session->contribution = null;
if ($contrib->isTransactionPart() && $contrib->transaction->getMissingAmount() > 0) {
*
* PHP version 5
*
- * Copyright © 2020 The Galette Team
+ * Copyright © 2020-2021 The Galette Team
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020 The Galette Team
+ * @copyright 2020-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.9.4dev - 2020-05-08
* @name TransactionsController
* @package Galette
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020 The Galette Team
+ * @copyright 2020-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.9.4dev - 2020-05-02
}
}
+ if (count($error_detected) === 0) {
+ $files_res = $trans->handleFiles($_FILES);
+ if (is_array($files_res)) {
+ $error_detected = array_merge($error_detected, $files_res);
+ }
+ }
+
if (count($error_detected) == 0) {
if ($trans->getMissingAmount() > 0) {
$rparams = [
}
/**
- * Handle files (photo and dynamics files
+ * Handle files (photo and dynamics files)
*
* @param array $files Files sent
*
);
}
}
- $this->dynamicsFiles($_FILES);
+ $this->dynamicsFiles($files);
if (count($this->errors) > 0) {
Analog::log(
*
* PHP version 5
*
- * Copyright © 2010-2014 The Galette Team
+ * Copyright © 2010-2021 The Galette Team
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2010-2014 The Galette Team
+ * @copyright 2010-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.7dev - 2010-03-11
* @name Contribution
* @package Galette
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2010-2014 The Galette Team
+ * @copyright 2010-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.7dev - 2010-03-11
{
return $this->sendmail;
}
+
+ /**
+ * Handle files (dynamics files)
+ *
+ * @param array $files Files sent
+ *
+ * @return array|true
+ */
+ public function handleFiles($files)
+ {
+ $this->errors = [];
+
+ $this->dynamicsFiles($files);
+
+ if (count($this->errors) > 0) {
+ Analog::log(
+ 'Some errors has been throwed attempting to edit/store a contribution files' . "\n" .
+ print_r($this->errors, true),
+ Analog::ERROR
+ );
+ return $this->errors;
+ } else {
+ return true;
+ }
+ }
}
*
* PHP version 5
*
- * Copyright © 2011-2014 The Galette Team
+ * Copyright © 2011-2021 The Galette Team
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2011-2014 The Galette Team
+ * @copyright 2011-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.7dev - 2011-06-20
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2011-2014 The Galette Team
+ * @copyright 2011-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
*/
'val_index' => $value['val_index'],
'item_id' => $value['item_id'],
'field_id' => $value['field_id'],
- 'field_form' => $value['field_form'], //:val_index
- 'val_index' => $value['old_val_index'] ?? $value['val_index'] //:old_val_index
+ 'field_form' => $value['field_form'],
+ 'old_val_index' => $value['old_val_index'] ?? $value['val_index'] //:old_val_index
];
$this->getUpdateStatement()->execute($params);
$this->has_changed = true;
*
* PHP version 5
*
- * Copyright © 2017-2018 The Galette Team
+ * Copyright © 2017-2021 The Galette Team
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2017-2018 The Galette Team
+ * @copyright 2017-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.9dev - 2017-05-26
* @name DynamicsTrait
* @package Galette
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2017-2018 The Galette Team
+ * @copyright 2017-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.9dev - 2017-05-26
$field_id,
$val_index
);
- unlink(GALETTE_FILES_PATH . $filename);
+ if (file_exists(GALETTE_FILES_PATH . $filename)) {
+ unlink(GALETTE_FILES_PATH . $filename);
+ }
$this->dynamics->setValue($this->id, $field_id, $val_index, '');
} else {
if ($fields[$field_id] instanceof Date && !empty(trim($value))) {
*
* PHP version 5
*
- * Copyright © 2011-2014 The Galette Team
+ * Copyright © 2011-2021 The Galette Team
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2011-2014 The Galette Team
+ * @copyright 2011-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.7dev - 2011-07-31
* @name Transaction
* @package Galette
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2010-2014 The Galette Team
+ * @copyright 2010-2021 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.7dev - 2010-03-11
$label = trim(trim($label, ':'), ' ');
return $label;
}
+
+ /**
+ * Handle files (dynamics files)
+ *
+ * @param array $files Files sent
+ *
+ * @return array|true
+ */
+ public function handleFiles($files)
+ {
+ $this->errors = [];
+
+ $this->dynamicsFiles($files);
+
+ if (count($this->errors) > 0) {
+ Analog::log(
+ 'Some errors has been throwed attempting to edit/store a transaction files' . "\n" .
+ print_r($this->errors, true),
+ Analog::ERROR
+ );
+ return $this->errors;
+ } else {
+ return true;
+ }
+ }
}
{block name="content"}
{if isset($members.list)}
- <form action="{if $contribution->id}{path_for name="doEditContribution" data=["type" => $type, "id" => $contribution->id]}{else}{path_for name="doAddContribution" data=["type" => $type]}{/if}" method="post">
+ <form action="{if $contribution->id}{path_for name="doEditContribution" data=["type" => $type, "id" => $contribution->id]}{else}{path_for name="doAddContribution" data=["type" => $type]}{/if}" enctype="multipart/form-data" method="post">
<div class="bigtable">
{if $contribution->isTransactionPart()}
{assign var="mid" value=$contribution->transaction->member}
{block name="content"}
{if isset($members.list)}
- <form action="{if $transaction->id}{path_for name="editTransaction" data=["id" => $transaction->id]}{else}{path_for name="addTransaction"}{/if}" method="post">
+ <form action="{if $transaction->id}{path_for name="editTransaction" data=["id" => $transaction->id]}{else}{path_for name="addTransaction"}{/if}" enctype="multipart/form-data" method="post">
<div class="bigtable">
<fieldset class="cssform">
<legend class="ui-state-active ui-corner-top">{_T string="Transaction details"}</legend>
{if $disabled} disabled="disabled"{/if}
/>
{elseif $field|is_a:'Galette\DynamicFields\File'}
- <label class="labelalign" for="info_field_{$field->getId()}_{$loop}_new">{_T string="new"}</label> <input type="file" name="info_field_{$field->getId()}_{$loop}" id="info_field_{$field->getId()}_{$loop}_new"
+ {if $object->id}
+ <label class="labelalign" for="info_field_{$field->getId()}_{$loop}_new">{_T string="new"}</label>
+ {/if}
+ <input
+ type="file"
+ name="info_field_{$field->getId()}_{$loop}"
+ id="info_field_{$field->getId()}_{$loop}_new"
{if $field->isRequired() and $valuedata eq ''} required="required"{/if}
{if $disabled} disabled="disabled"{/if}
/>
- <label class="labelalign" for="info_field_{$field->getId()}_{$loop}_current">{_T string="current"}</label> <input type="text" name="info_field_{$field->getId()}_{$loop}" id="info_field_{$field->getId()}_{$loop}_current" disabled="disabled"
- value="{$valuedata}"
- />
- <label class="labelalign" for="info_field_{$field->getId()}_{$loop}_delete">{_T string="delete"}</label> <input type="checkbox" name="info_field_{$field->getId()}_{$loop}" id="info_field_{$field->getId()}_{$loop}_delete"
+ {if $object->id}
+ <label class="labelalign" for="info_field_{$field->getId()}_{$loop}_current">{_T string="current"}</label>
+ <a href="{path_for name="getDynamicFile" data=["id" => $object->id, "fid" => $field->getId(), "pos" => $loop, "name" => $valuedata]}">
+ {$valuedata}
+ </a>
+ - <label class="labelalign" for="info_field_{$field->getId()}_{$loop}_delete">
+ {_T string="delete"}
+ </label>
+ <input
+ type="checkbox"
+ name="info_field_{$field->getId()}_{$loop}"
+ id="info_field_{$field->getId()}_{$loop}_delete"
onclick="this.form.info_field_{$field->getId()}_{$loop}_new.disabled = this.checked;"
/>
+ {/if}
{/if}
{/function}