Giter Site home page Giter Site logo

Comments (8)

txmodxoops avatar txmodxoops commented on July 30, 2024

What you see in the address bar of the browser, add or edit?

from tdmcreate.

dalaniz130 avatar dalaniz130 commented on July 30, 2024

I see add.

from tdmcreate.

txmodxoops avatar txmodxoops commented on July 30, 2024

Try changing in the templates/admin of the new module, the affected file that op=add to op=edit where there is the edit link, see if it works well this way.

from tdmcreate.

dalaniz130 avatar dalaniz130 commented on July 30, 2024
  1. The problem is related to a variable that is not recognized. Now I understand it. op=add and save are working, but edit and delete are not.
  2. The call from the template patient.tpl is: /../admin/patients.php?op=edit&patient_id=1
  3. The debugger show:
    Notice: Undefined variable: patientId in file /modules/eclinic/admin/patients.php line 100
    you can see the attachment below
    patient_admin

from tdmcreate.

dalaniz130 avatar dalaniz130 commented on July 30, 2024

Sorry I had observed that this issue is close but if did it . I did bymistake. How to open it again?

from tdmcreate.

txmodxoops avatar txmodxoops commented on July 30, 2024

You should be more precise, I create match modules, test them and when edit something, it always works.

You owe me to see the template file

from tdmcreate.

dalaniz130 avatar dalaniz130 commented on July 30, 2024

I want to apologize and I will be more precise. I can send the module to you if you need it

1 Folders

  1. The module created is eclinic and the folder structure is the following:
    1.1 modulo eclinic
    modulo eclinic
    1.2 admin
    admin
    1.3 assets
    assets
    1.4 Blocks
    blocks
    1.5 class
    class
    1.6 include
    include
    1.7 language/english
    language-english
    1.8 preloads
    preloads
    1.9 sql
    sql
    1.10 templates
    templates
    1.11 templates/admin
    templates-admin

1.12 templates/blocks
templates-blocks

  1. Files on folders admin, class and templates/admin/patients.tpl.
    Below you will find a three files. 2.1 admin/patients.php; 2.2 class/patients.php; 2.3 template/patients.tpl

2.1 Files: eclinic/admin/patients.php

getConfig('adminpager')); $templateMain = 'eclinic_admin_patients.tpl'; $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('patients.php')); $adminMenu->addItemButton(_AM_ECLINIC_ADD_PATIENT, 'patients.php?op=new', 'add'); $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); $patientsCount = $patientsHandler->getCountPatients(); $patientsAll = $patientsHandler->getAllPatients($start, $limit); $GLOBALS['xoopsTpl']->assign('patients_count', $patientsCount); $GLOBALS['xoopsTpl']->assign('eclinic_url', ECLINIC_URL); $GLOBALS['xoopsTpl']->assign('eclinic_upload_url', ECLINIC_UPLOAD_URL); // Table view if ($patientsCount > 0) { foreach (array_keys($patientsAll) as $i) { $patient = $patientsAll[$i]->getValuesPatients(); $GLOBALS['xoopsTpl']->append('patients_list', $patient); unset($patient); } if ( $patientsCount > $limit ) { include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; $pagenav = new XoopsPageNav($patientsCount, $limit, $start, 'start', 'op=list&limit=' . $limit); $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); } } else { $GLOBALS['xoopsTpl']->assign('error', _AM_ECLINIC_THEREARENT_PATIENTS); } break; case 'new': $templateMain = 'eclinic_admin_patients.tpl'; $adminMenu->addItemButton(_AM_ECLINIC_PATIENTS_LIST, 'patients.php', 'list'); $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('patients.php')); $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); // Get Form $patientsObj =& $patientsHandler->create(); $form = $patientsObj->getFormPatients(); $GLOBALS['xoopsTpl']->assign('form', $form->render()); break; case 'save': if ( !$GLOBALS['xoopsSecurity']->check() ) { redirect_header('patients.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } if (isset($patientId)) { $patientsObj =& $patientsHandler->get($patientId); } else { $patientsObj =& $patientsHandler->create(); } $patientsObj->setVar('patient_firstname', $_POST['patient_firstname']); $patientsObj->setVar('patient_lastname', $_POST['patient_lastname']); $patientsObj->setVar('patient_tel', $_POST['patient_tel']); // Insert Data if ($patientsHandler->insert($patientsObj)) { redirect_header('patients.php?op=list', 2, _AM_ECLINIC_FORM_OK); } // Get Form $GLOBALS['xoopsTpl']->assign('error', $patientsObj->getHtmlErrors()); $form =& $patientsObj->getFormPatients(); $GLOBALS['xoopsTpl']->assign('form', $form->render()); break; case 'edit': $templateMain = 'eclinic_admin_patients.tpl'; $adminMenu->addItemButton(_AM_ECLINIC_ADD_PATIENT, 'patients.php?op=new', 'add'); $adminMenu->addItemButton(_AM_ECLINIC_PATIENTS_LIST, 'patients.php', 'list'); $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('patients.php')); $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); // Get Form //$patientsObj = $patientsHandler->get($patientId); $patientsObj = $eclinic->getHandler('patients')->get($patient_id); $form = $patientsObj->getFormPatients(); $GLOBALS['xoopsTpl']->assign('form', $form->render()); break; case 'delete': $patientsObj =& $patientsHandler->get($patientId); if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { if ( !$GLOBALS['xoopsSecurity']->check() ) { redirect_header('patients.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); } if ($patientsHandler->delete($patientsObj)) { redirect_header('patients.php', 3, _AM_ECLINIC_FORM_DELETE_OK); } else { $GLOBALS['xoopsTpl']->assign('error', $patientsObj->getHtmlErrors()); } } else { xoops_confirm(array('ok' => 1, 'patient_id' => $patientId, 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_AM_ECLINIC_FORM_SURE_DELETE, $patientsObj->getVar('patient_firstname'))); } break; } include __DIR__ .'/footer.php'; 2.2 eclinic/class/patients.php eclinic = EclinicHelper::getInstance(); $this->initVar('patient_id', XOBJ_DTYPE_INT); $this->initVar('patient_firstname', XOBJ_DTYPE_TXTBOX); $this->initVar('patient_lastname', XOBJ_DTYPE_TXTBOX); $this->initVar('patient_tel', XOBJ_DTYPE_TXTBOX); } /* - @static function &getInstance - @param null */ public static function &getInstance() { static $instance = false; if(!$instance) { $instance = new self(); } return $instance; } /* - Get form * - @param mixed $action _/ /_* - @param bool|false $action - @return XoopsThemeForm */ public function getFormPatients($action = false) { if($action === false) { $action = $_SERVER['REQUEST_URI']; } global $xoopsUser, $xoopsModule; // Permissions for uploader $gpermHandler =& xoops_gethandler('groupperm'); $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; if($xoopsUser) { if( !$xoopsUser->isAdmin($xoopsModule->mid()) ) { $permissionUpload =($gpermHandler->checkRight('eclinic_ac', 32, $groups, $xoopsModule->getVar('mid'))) ? true : false ; }else{ $permissionUpload = true; } }else{ $permissionUpload = ($gpermHandler->checkRight('eclinic_ac', 32, $groups, $xoopsModule->getVar('mid'))) ? true : false ; } // Title $title = $this->isNew() ? sprintf(_AM_ECLINIC_PATIENT_ADD) : sprintf(_AM_ECLINIC_PATIENT_EDIT); // Get Theme Form xoops_load('XoopsFormLoader'); $form = new XoopsThemeForm($title, 'form', $action, 'post', true); $form->setExtra('enctype="multipart/form-data"'); // Patients handler //$patientsHandler =& $this->eclinic->getHandler('patients'); // Form Text PatientFirstname $form->addElement( new XoopsFormText(_AM_ECLINIC_PATIENT_FIRSTNAME, 'patient_firstname', 50, 255, $this->getVar('patient_firstname')), true ); // Form Text PatientLastname $form->addElement( new XoopsFormText(_AM_ECLINIC_PATIENT_LASTNAME, 'patient_lastname', 50, 255, $this->getVar('patient_lastname')), true ); // Form Text PatientTel $form->addElement( new XoopsFormText(_AM_ECLINIC_PATIENT_TEL, 'patient_tel', 50, 255, $this->getVar('patient_tel')), true ); // Permissions $memberHandler = & xoops_gethandler( 'member' ); $groupList = $memberHandler->getGroupList(); $gpermHandler = &xoops_gethandler( 'groupperm' ); $fullList = array_keys( $groupList ); global $xoopsModule; if( !$this->isNew() ) { $groupsIdsApprove = $gpermHandler->getGroupIds( 'eclinic_approve', $this->getVar( 'patient_id' ), $xoopsModule->getVar( 'mid' ) ); $groupsIdsSubmit = $gpermHandler->getGroupIds( 'eclinic_submit', $this->getVar( 'patient_id' ), $xoopsModule->getVar( 'mid' ) ); $groupsIdsView = $gpermHandler->getGroupIds( 'eclinic_view', $this->getVar( 'patient_id' ), $xoopsModule->getVar( 'mid' ) ); $groupsIdsApprove = array_values( $groupsIdsApprove ); $groupsCanApproveCheckbox = new XoopsFormCheckBox( _AM_ECLINIC_PERMISSIONS_APPROVE, 'groups_approve[]', $groupsIdsApprove ); $groupsIdsSubmit = array_values( $groupsIdsSubmit ); $groupsCanSubmitCheckbox = new XoopsFormCheckBox( _AM_ECLINIC_PERMISSIONS_SUBMIT, 'groups_submit[]', $groupsIdsSubmit ); $groupsIdsView = array_values( $groupsIdsView ); $groupsCanViewCheckbox = new XoopsFormCheckBox( _AM_ECLINIC_PERMISSIONS_VIEW, 'groups_view[]', $groupsIdsView ); } else { $groupsCanApproveCheckbox = new XoopsFormCheckBox( _AM_ECLINIC_PERMISSIONS_APPROVE, 'groups_approve[]', $fullList ); $groupsCanSubmitCheckbox = new XoopsFormCheckBox( _AM_ECLINIC_PERMISSIONS_SUBMIT, 'groups_submit[]', $fullList ); $groupsCanViewCheckbox = new XoopsFormCheckBox( _AM_ECLINIC_PERMISSIONS_VIEW, 'groups_view[]', $fullList ); } // For approve $groupsCanApproveCheckbox->addOptionArray( $groupList ); $form->addElement( $groupsCanApproveCheckbox ); // For submit $groupsCanSubmitCheckbox->addOptionArray( $groupList ); $form->addElement( $groupsCanSubmitCheckbox ); // For view $groupsCanViewCheckbox->addOptionArray( $groupList ); $form->addElement( $groupsCanViewCheckbox ); // Send $form->addElement(new XoopsFormHidden('op', 'save')); $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); return $form; } /** - Get Values */ public function getValuesPatients($keys = null, $format = null, $maxDepth = null) { $ret = $this->getValues($keys, $format, $maxDepth); $ret['id'] = $this->getVar('patient_id'); $ret['firstname'] = $this->getVar('patient_firstname'); $ret['lastname'] = $this->getVar('patient_lastname'); $ret['tel'] = $this->getVar('patient_tel'); return $ret; } /** - Returns an array representation of the object * - @return array **/ public function toArray() { $ret = array(); $vars = $this->getVars(); foreach( array_keys( $vars ) as $var ) { $ret[$var] = $this->getVar( $var ); } return $ret; } } /* - Class Object Handler EclinicPatients _/ class EclinicPatientsHandler extends XoopsPersistableObjectHandler { /_ - @var mixed */ private $eclinic = null; /* - Constructor * - @param string $db */ public function __construct(&$db) { parent::__construct($db, 'eclinic_patients', 'eclinicpatients', 'patient_id', 'patient_firstname'); $this->eclinic = EclinicHelper::getInstance(); } /** - @param bool $isNew * - @return object */ public function &create($isNew = true) { return parent::create($isNew); } /** - retrieve a field * - @param int $i field id - @return mixed reference to the {@link TDMCreateFields} object */ public function &get($i = null, $fields = null) { return parent::get($i, $fields); } /** - get inserted id * - @param null - @return integer reference to the {@link TDMCreateFields} object */ public function &getInsertId() { return $this->db->getInsertId(); } /** - get IDs of objects matching a condition * - @param object $criteria {@link CriteriaElement} to match - @return array of object IDs */ public function &getIds($criteria) { return parent::getIds($criteria); } /** - insert a new field in the database * - @param object $field reference to the {@link TDMCreateFields} object - @param bool $force * - @return bool FALSE if failed, TRUE if already present and unchanged or successful */ public function &insert(&$field, $force = false) { if(!parent::insert($field, $force)) { return false; } return true; } /** - Get Count Patients */ public function getCountPatients($start = 0, $limit = 0, $sort = 'patient_id ASC, patient_firstname', $order = 'ASC') { $criteria = new CriteriaCompo(); $criteria->setSort($sort); $criteria->setOrder($order); $criteria->setStart($start); $criteria->setLimit($limit); return $this->getCount($criteria); } /** - Get All Patients */ public function getAllPatients($start = 0, $limit = 0, $sort = 'patient_id ASC, patient_firstname', $order = 'ASC') { $criteria = new CriteriaCompo(); $criteria->setSort($sort); $criteria->setOrder($order); $criteria->setStart($start); $criteria->setLimit($limit); return $this->getAll($criteria); } } 2.3 eclinic/templates/eclinic_admin_patients.tpl <{include file='db:eclinic_admin_header.tpl'}>

The Record Count Is: <{$patients_count}>; and FirstName: <{$patient.firstname}>

Patients List

<{$patients_list}>

<{if $patients_list}> <{if $patients_count}> <{foreach item=patient from=$patients_list}> <{/foreach}> <{/if}>
<{$smarty.const._AM_ECLINIC_PATIENT_ID}> <{$smarty.const._AM_ECLINIC_PATIENT_FIRSTNAME}> <{$smarty.const._AM_ECLINIC_PATIENT_LASTNAME}> <{$smarty.const._AM_ECLINIC_PATIENT_TEL}> <{$smarty.const._AM_ECLINIC_FORM_ACTION}>
<{$patient.id}> <{$patient.firstname}> <{$patient.lastname}> <{$patient.tel}> patients patients
 
<{if $pagenav}>
<{$pagenav}>
<{/if}> <{/if}> <{if $form}> <{$form}> <{/if}> <{if $error}>
<{$error}>
<{/if}>
<{include file='db:eclinic_admin_footer.tpl'}> If you need anything else please let me know. I do not know how to attach files with all colors and php format sorry.

from tdmcreate.

txmodxoops avatar txmodxoops commented on July 30, 2024

Before you send me the zipped package module, let me see the screenshots here, the module is in admin & frontend ... thanks

from tdmcreate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.