]> git.agnieray.net Git - galette.git/commitdiff
Duplicate member; closes #633
authorJohan Cwiklinski <johan@x-tnd.be>
Thu, 10 May 2018 06:49:00 +0000 (08:49 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Thu, 10 May 2018 06:59:43 +0000 (08:59 +0200)
galette/includes/dependencies.php
galette/includes/routes/members.routes.php
galette/lib/Galette/Entity/Adherent.php
galette/templates/default/voir_adherent.tpl
galette/webroot/themes/default/galette.css
galette/webroot/themes/default/images/duplicate.png [new file with mode: 0644]

index e67ba579897a5265fe5b0f28de579b0948f59a65..e8db6cf19e4d6d7d5ef0c50198dce1797f96bbd0 100644 (file)
@@ -336,7 +336,8 @@ $container['acls'] = function ($c) {
         'setRegistered'             => 'admin',
         'masschangeMembers'         => 'groupmanager',
         'massstoremembers'          => 'groupmanager',
-        'masschangeMembersReview'   => 'groupmanager'
+        'masschangeMembersReview'   => 'groupmanager',
+        'duplicateMember'           => 'staff'
     ];
 
     foreach ($c['plugins']->getModules() as $plugin) {
index a087866a9af90b5411faba7a6a81abff51689bd9..d05e6b2924bb96b7533ba797f50218ccf9e3bc2e 100644 (file)
@@ -3140,3 +3140,20 @@ $app->post(
         }
     }
 )->setName('massstoremembers')->add($authenticate);
+
+//Duplicate member
+$app->get(
+    __('/members', 'routes') . __('/duplicate', 'routes') . '/{' . Adherent::PK . ':\d+}',
+    function ($request, $response, $args) {
+        $id_adh = (int)$args[Adherent::PK];
+        $adh = new Adherent($this->zdb, $id_adh, ['dynamics' => true]);
+        $adh->setDuplicate();
+
+        //store entity in session
+        $this->session->member = $adh;
+
+        return $response
+            ->withStatus(301)
+            ->withHeader('Location', $this->router->pathFor('editmember', ['action' => __('add', 'routes')]));
+    }
+)->setName('duplicateMember')->add($authenticate);
index 5d3e87d2770431de626c874c25e39677eb8e2c14..39a155c3c22f11ef67eb788a5eac9146a517bc94 100644 (file)
@@ -1723,4 +1723,27 @@ class Adherent
             return true;
         }
     }
+
+    /**
+     * Set member as duplicate
+     *
+     * @return void
+     */
+    public function setDuplicate()
+    {
+        //mark as duplicated
+        $infos = $this->_others_infos_admin;
+        $this->_others_infos_admin = str_replace(
+            ['%name', '%id'],
+            [$this->sname, $this->_id],
+            _T('Duplicated from %name (%id)')
+        );
+        if (!empty($infos)) {
+            $this->_others_infos_admin .= "\n" . $infos;
+        }
+        //drop id_adh
+        $this->_id = null;
+        //drop mail, must be unique
+        $this->_email = null;
+    }
 }
index 7ea6a969c4c752f2192aa68cba45011892408097..2df2332e713707731a0c58cf9b089d37aea37021 100644 (file)
@@ -37,6 +37,9 @@
             <li>
                 <a class="button" id="btn_addcontrib" href="{path_for name="contribution" data=["type" => {_T string="donation" domain="routes"}, "action" => {_T string="add" domain="routes"}]}?id_adh={$member->id}">{_T string="Add a donation"}</a>
             </li>
+            <li>
+                <a class="button" href="{path_for name="duplicateMember" data=["id_adh" => $member->id]}" id="btn_duplicate" title="{_T string="Create a new member with %name information." pattern="/%name/" replace=$member->sname}">{_T string="Duplicate"}</a>
+            </li>
 {/if}
 {* If some additionnals actions should be added from plugins, we load the relevant template file
 We have to use a template file, so Smarty will do its work (like replacing variables). *}
index fb78d971530879711cb6494a30b6ffc0d395bf9d..0dca686028a238c32f437b754d725adf290e2944 100644 (file)
@@ -868,7 +868,7 @@ legend #btnadd_small {
     background-image:url(images/printer.png), url("jquery-ui/images/ui-bg_glass_75_ffb619_1x400.png");
 }
 
-#btn_membercard, #btn_edit, #btn_contrib, #btn_addcontrib, #btn_lostpassword, #btn_adhesionform {
+#btn_membercard, #btn_edit, #btn_contrib, #btn_addcontrib, #btn_lostpassword, #btn_adhesionform, #btn_duplicate {
     padding-top:30px!important;
     padding-left: 0!important;
     display: block;
@@ -909,6 +909,13 @@ legend #btnadd_small {
     background-image: url(images/add_contribution.png), url("jquery-ui/images/ui-bg_glass_75_ffb619_1x400.png");
 }
 
+#btn_duplicate {
+    background-image:url(images/duplicate.png), url("jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png");
+}
+#btn_duplicate.ui-state-hover {
+    background-image: url(images/duplicate.png), url("jquery-ui/images/ui-bg_glass_75_ffb619_1x400.png");
+}
+
 .ui-state-default.btn_pdf {
     background-image: url(images/icon-pdf.png), url("jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png");
 }
diff --git a/galette/webroot/themes/default/images/duplicate.png b/galette/webroot/themes/default/images/duplicate.png
new file mode 100644 (file)
index 0000000..756debb
Binary files /dev/null and b/galette/webroot/themes/default/images/duplicate.png differ