mambax7 /
pedigree
| 1 | <?php |
||
| 2 | /* |
||
| 3 | You may not change or alter any portion of this comment or credits |
||
| 4 | of supporting developers from this source code or any supporting source code |
||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | |||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Pedigree module for XOOPS |
||
| 14 | * |
||
| 15 | * @copyright XOOPS Project (https://xoops.org) |
||
| 16 | * @license GPL 2.0 or later |
||
| 17 | * @package pedigree |
||
| 18 | * @since 2.5.x |
||
| 19 | * @author XOOPS Development Team ( [email protected] ) - ( https://xoops.org ) |
||
| 20 | */ |
||
| 21 | |||
| 22 | use Xmf\Request; |
||
| 23 | use XoopsModules\Pedigree; |
||
| 24 | |||
| 25 | require_once __DIR__ . '/admin_header.php'; |
||
| 26 | |||
| 27 | xoops_cp_header(); |
||
| 28 | //$adminObject = \Xmf\Module\Admin::getInstance(); |
||
| 29 | |||
| 30 | $ownerHandler = Pedigree\Helper::getInstance()->getHandler('Owner'); |
||
| 31 | |||
| 32 | //It recovered the value of argument op in URL$ |
||
| 33 | $op = Request::getCmd('op', 'list'); |
||
| 34 | switch ($op) { |
||
| 35 | case 'list': |
||
| 36 | default: |
||
| 37 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 38 | $adminObject->addItemButton(_AM_PEDIGREE_NEWOWNER, 'owner.php?op=new_owner', 'add'); |
||
| 39 | $adminObject->displayButton('left'); |
||
| 40 | $criteria = new \CriteriaCompo(); |
||
| 41 | $criteria->setSort('id'); |
||
| 42 | $criteria->setOrder('ASC'); |
||
| 43 | $numrows = $ownerHandler->getCount(); |
||
| 44 | $owner_arr = $ownerHandler->getAll($criteria); |
||
| 45 | |||
| 46 | //Table view |
||
| 47 | if ($numrows > 0) { |
||
| 48 | echo "<table width='100%' cellspacing='1' class='outer'> |
||
| 49 | <tr> |
||
| 50 | <th align=\"center\">" . _AM_PEDIGREE_OWNER_FIRSTNAME . '</th> |
||
| 51 | <th class="center">' . _AM_PEDIGREE_OWNER_LASTNAME . '</th> |
||
| 52 | <th class="center">' . _AM_PEDIGREE_OWNER_POSTCODE . '</th> |
||
| 53 | <th class="center">' . _AM_PEDIGREE_OWNER_CITY . '</th> |
||
| 54 | <th class="center">' . _AM_PEDIGREE_OWNER_STREETNAME . '</th> |
||
| 55 | <th class="center">' . _AM_PEDIGREE_OWNER_HOUSENUMBER . '</th> |
||
| 56 | <th class="center">' . _AM_PEDIGREE_OWNER_PHONENUMBER . '</th> |
||
| 57 | <th class="center">' . _AM_PEDIGREE_OWNER_EMAILADRES . '</th> |
||
| 58 | <th class="center">' . _AM_PEDIGREE_OWNER_WEBSITE . '</th> |
||
| 59 | <th class="center">' . _AM_PEDIGREE_OWNER_USER . "</th> |
||
| 60 | |||
| 61 | <th align='center' width='10%'>" . _AM_PEDIGREE_FORMACTION . '</th> |
||
| 62 | </tr>'; |
||
| 63 | |||
| 64 | $class = 'odd'; |
||
| 65 | |||
| 66 | foreach (array_keys($owner_arr) as $i) { |
||
| 67 | if (0 == $owner_arr[$i]->getVar('owner_pid')) { |
||
| 68 | echo "<tr class='" . $class . "'>"; |
||
| 69 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
| 70 | echo '<td class="center">' . $owner_arr[$i]->getVar('firstname') . '</td>'; |
||
| 71 | echo '<td class="center">' . $owner_arr[$i]->getVar('lastname') . '</td>'; |
||
| 72 | echo '<td class="center">' . $owner_arr[$i]->getVar('postcode') . '</td>'; |
||
| 73 | echo '<td class="center">' . $owner_arr[$i]->getVar('city') . '</td>'; |
||
| 74 | echo '<td class="center">' . $owner_arr[$i]->getVar('streetname') . '</td>'; |
||
| 75 | echo '<td class="center">' . $owner_arr[$i]->getVar('housenumber') . '</td>'; |
||
| 76 | echo '<td class="center">' . $owner_arr[$i]->getVar('phonenumber') . '</td>'; |
||
| 77 | echo '<td class="center">' . $owner_arr[$i]->getVar('emailadres') . '</td>'; |
||
| 78 | echo '<td class="center">' . $owner_arr[$i]->getVar('website') . '</td>'; |
||
| 79 | echo '<td class="center">' . $owner_arr[$i]->getVar('user') . '</td>'; |
||
| 80 | |||
| 81 | echo "<td class='center' width='10%'> |
||
| 82 | <a href='owner.php?op=edit_owner&id=" . $owner_arr[$i]->getVar('id') . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
| 83 | <a href='owner.php?op=delete_owner&id=" . $owner_arr[$i]->getVar('id') . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||
| 84 | </td>"; |
||
| 85 | echo '</tr>'; |
||
| 86 | } |
||
| 87 | } |
||
| 88 | echo '</table><br><br>'; |
||
| 89 | } |
||
| 90 | |||
| 91 | break; |
||
| 92 | |||
| 93 | case 'new_owner': |
||
| 94 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 95 | $adminObject->addItemButton(_AM_PEDIGREE_OWNERLIST, 'owner.php?op=list', 'list'); |
||
| 96 | $adminObject->displayButton('left'); |
||
| 97 | |||
| 98 | $obj = $ownerHandler->create(); |
||
| 99 | $form = $obj->getForm(); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 100 | $form->display(); |
||
| 101 | break; |
||
| 102 | |||
| 103 | case 'save_owner': |
||
| 104 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 105 | $helper->redirect('admin/owner.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 106 | } |
||
| 107 | if (isset($_REQUEST['id'])) { |
||
| 108 | $obj = $ownerHandler->get($_REQUEST['id']); |
||
| 109 | } else { |
||
| 110 | $obj = $ownerHandler->create(); |
||
| 111 | } |
||
| 112 | |||
| 113 | //Form firstname |
||
| 114 | $obj->setVar('firstname', $_REQUEST['firstname']); |
||
| 115 | //Form lastname |
||
| 116 | $obj->setVar('lastname', $_REQUEST['lastname']); |
||
| 117 | //Form postcode |
||
| 118 | $obj->setVar('postcode', $_REQUEST['postcode']); |
||
| 119 | //Form city |
||
| 120 | $obj->setVar('city', $_REQUEST['city']); |
||
| 121 | //Form streetname |
||
| 122 | $obj->setVar('streetname', $_REQUEST['streetname']); |
||
| 123 | //Form housenumber |
||
| 124 | $obj->setVar('housenumber', $_REQUEST['housenumber']); |
||
| 125 | //Form phonenumber |
||
| 126 | $obj->setVar('phonenumber', $_REQUEST['phonenumber']); |
||
| 127 | //Form emailadres |
||
| 128 | $obj->setVar('emailadres', $_REQUEST['emailadres']); |
||
| 129 | //Form website |
||
| 130 | $obj->setVar('website', $_REQUEST['website']); |
||
| 131 | //Form user |
||
| 132 | $obj->setVar('user', $_REQUEST['user']); |
||
| 133 | |||
| 134 | if ($ownerHandler->insert($obj)) { |
||
| 135 | $helper->redirect('admin/owner.php?op=list', 2, _AM_PEDIGREE_FORMOK); |
||
| 136 | } |
||
| 137 | |||
| 138 | echo $obj->getHtmlErrors(); |
||
| 139 | $form = $obj->getForm(); |
||
| 140 | $form->display(); |
||
| 141 | break; |
||
| 142 | |||
| 143 | case 'edit_owner': |
||
| 144 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 145 | $adminObject->addItemButton(_AM_PEDIGREE_NEWOWNER, 'owner.php?op=new_owner', 'add'); |
||
| 146 | $adminObject->addItemButton(_AM_PEDIGREE_OWNERLIST, 'owner.php?op=list', 'list'); |
||
| 147 | $adminObject->displayButton('left'); |
||
| 148 | $obj = $ownerHandler->get($_REQUEST['id']); |
||
| 149 | $form = $obj->getForm(); |
||
| 150 | $form->display(); |
||
| 151 | break; |
||
| 152 | |||
| 153 | case 'delete_owner': |
||
| 154 | $obj = $ownerHandler->get($_REQUEST['id']); |
||
| 155 | if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
||
| 156 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 157 | $helper->redirect('admin/owner.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 158 | } |
||
| 159 | if ($ownerHandler->delete($obj)) { |
||
| 160 | $helper->redirect('admin/owner.php', 3, _AM_PEDIGREE_FORMDELOK); |
||
| 161 | } else { |
||
| 162 | echo $obj->getHtmlErrors(); |
||
| 163 | } |
||
| 164 | } else { |
||
| 165 | xoops_confirm(['ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete_owner'], $_SERVER['REQUEST_URI'], sprintf(_AM_PEDIGREE_FORMSUREDEL, $obj->getVar('owner'))); |
||
| 166 | } |
||
| 167 | break; |
||
| 168 | } |
||
| 169 | require_once __DIR__ . '/admin_footer.php'; |
||
| 170 |