Re: [development] development Digest, Vol 97, Issue 27
Re: creating pop-up window for delete and edit actions in table in module file Hi Carl and Amit, I want to know whether I can use that PopUps-API Module into my module .if I can use it then How I can implement it .Please give steps in breif or suggest related study material for it. Mahesh Gajabar On Wed, Jan 12, 2011 at 12:44 PM, <development-request@drupal.org> wrote:
Send development mailing list submissions to development@drupal.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.drupal.org/mailman/listinfo/development or, via email, send a message with subject or body 'help' to development-request@drupal.org
You can reach the person managing the list at development-owner@drupal.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of development digest..."
Today's Topics:
1. Re: creating pop-up window for delete and edit actions in table in module file (Carl Wiedemann) 2. Re: creating pop-up window for delete and edit actions in table in module file (Amit Vyas)
----------------------------------------------------------------------
Message: 1 Date: Wed, 12 Jan 2011 00:05:48 -0700 From: Carl Wiedemann <carl.wiedemann@gmail.com> Subject: Re: [development] creating pop-up window for delete and edit actions in table in module file To: development@drupal.org Message-ID: <AANLkTikkSpGW3ex4JKq8q3QVtS4AzAFVe1ZAhJZG-74D@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
Consider http://drupal.org/project/popups
On Tue, Jan 11, 2011 at 11:37 PM, mahesh gajabar <mahesh143an@gmail.com
wrote:
Hi,
I have written a custome module table for showing some information which is fetched from database and every row is having edit and delete actions. Both are working fine. But whenever I click on on edit or delete action action it opens in other window leaving current page. I want these actions to be taken place in pop-up window.
My table on drupal screen is as follows
*SlNo*
*Doctor Name*
*Gender*
*Status*
*Action*
2
Jayaram Srinivasan
male
inactive
Edit <http://localhost/fr/doctor/edit/2> | Delete< http://localhost/fr/doctor/delete/2>
3
Pavithra M
female
active
Edit <http://localhost/fr/doctor/edit/3> | Delete< http://localhost/fr/doctor/delete/3>
4
Ravi Mandayam
male
active
Edit <http://localhost/fr/doctor/edit/4> | Delete< http://localhost/fr/doctor/delete/4>
when i click delete button i should get pop-up window with the dialogue like this;
Are You Sure You Want To Delete This Doctor? This action cannot be undone. Cancel <http://localhost/fr/doctor>
When I click edit button I should get my edit form, First Name: Last Name: Gender: male female Status: active inactive Cancel <http://localhost/fr/doctor>
complete code of my module file is as follows:
*<?php
function doctor_menu() { $items = array();
$items['doctor'] = array( 'title' => t('Doctors'), 'page callback' =>'doctors_list', 'access arguments' => array('access doctor'), 'type' => MENU_NORMAL_ITEM, );
$items['doctor/delete/%doctor_user'] = array( 'title' => t('Delete doctor'), 'page callback' => 'drupal_get_form', 'page arguments' => array('doctor_delete_confirm', 2), 'access arguments' => array('access doctor'), 'type' => MENU_CALLBACK, ); $items['doctor/edit/%doctor_user'] = array( 'title' => t('Edit Form'), 'page callback' => 'drupal_get_form', 'page arguments' => array('doctor_edit_confirm', 2), 'access arguments' => array('access doctor'), 'type' => MENU_NORMAL_ITEM, ); return $items; }
function doctors_list() { $header = array(t(Sl.No),t('Doctor Name'), t('Gender'), t('Status'), t('Action'));
$query = "SELECT * FROM {doctor}"; $rs = db_query($query);
$row = array();
if ($rs) { while ($data = db_fetch_object($rs)) { $doctorid = $data->doctorid; $gender = $data->gender; $status = $data->status ; $row[] = array($doctorid,stripslashes(ucwords($data->firstname)) . ' ' . stripslashes(ucwords($data->lastname)), $gender, $status, "<a href='doctor/edit/{$data->doctorid}'>" . t('Edit') . "</a> |<a href='doctor/delete/{$data->doctorid}'> ". t('Delete')."</a>" ); } }
$str .= theme_table($header, $row);
return $str; } function doctor_user_load($doctorid) { $query = "SELECT * FROM {doctor} WHERE doctorid = %d"; $rs = db_query($query, $doctorid);
if ($rs) { while ($data = db_fetch_object($rs)) { return $data; } }
return FALSE; }
function popup() { window.confirm(); return false; }
function doctor_delete_confirm(&$form_state, $doctor) { $form['_doctor'] = array( '#type' => 'value', '#value' => $doctor, );
return confirm_form($form, t('Are you sure you want to delete this doctor?'), isset($_GET['destination']) ? $_GET['destination'] : "doctor", t('This action cannot be undone.'), t('Delete'), t('Cancel')); }
function doctor_delete_confirm_submit($form, &$form_state) { $form_values = $form_state['values'];
if ($form_state['values']['confirm']) { $doctor = $form_state['values']['_doctor'];
$query = "DELETE FROM {doctor} where doctorid= $doctor->doctorid"; $rs = db_query($query); drupal_set_message(t('Doctor has been deleted successfully.')); } drupal_goto("doctor"); }
function doctor_edit_confirm(&$form_state,$doctor){ $form = array(); $form['_doctors'] = array( '#type' => 'value', '#value' => $doctor, );
$query = "SELECT * FROM {doctor} where doctorid=%d"; $rs = db_query($query,$doctor->doctorid); $data=db_fetch_object($rs); $firstname=$data->firstname; $lastname=$data->lastname; $gender1 = $data->gender; $gender = $gender1 ? 0: 1; $status1 = $data->status ; $status = $status1 ? 1: 0; $form['firstname']=array( '#title'=>t('First Name'), '#type'=>'textfield', '#default_value'=>$data->firstname,
); $form['lastname']=array( '#title'=>t('Last Name'), '#type'=>'textfield', '#default_value' => $lastname, ); $form['gender']=array( '#title'=>t('Gender'), '#type'=>'radios',
'#options' => array(t('male'), t('female')), '#default_value' => variable_get('gender',$gender), ); $form['status']=array( '#title'=>t('Status'), '#type'=>'radios', '#options' => array(t('active'), t('inactive')), '#default_value' => variable_get('status',$status),
);
return confirm_form($form,t(''), isset($_GET['destination']) ? $_GET['destination'] : "doctor", t(''), t('Save'), t('Cancel')); }
function doctor_edit_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { $doctor = $form_state['values']['_doctors']; $form_state['values']['doctorid'] = $doctor->doctorid; $firstname = $form_state['values']['firstname']; $lastname = $form_state['values']['lastname']; $gender1= $form_state['values']['gender']; $gender = $gender1 ? t('female') : t('male'); $status1 = $form_state['values']['status']; $status = $status1 ? t('inactive') : t('active'); $query = "UPDATE {doctor} SET firstname = '$firstname', lastname= '$lastname', gender = '$gender', status = '$status' WHERE doctorid=%d"; $rs = db_query($query,$doctor->doctorid); } drupal_goto("doctor"); }
*Any help appreciated.*
* *Regards,* Mahesh Gajabar
Hello Mahesh, On Wed, 2011-01-12 at 14:03 +0530, mahesh gajabar wrote:
Re: creating pop-up window for delete and edit actions in table in module file
Your question, like a few I've seen here before seem to be hardly appropriate for a "devel" list. (Usually "devel" lists are lists regarding the development *of* the product not *with* it.) Perhaps you can keep them on the support list instead of cross posting. Or you could start doing your homework all by yourself and only post questions if you are really stuck. What triggered me to write this mail is the enormous size of your mails, more than the inappropriate location for your post. Could you please _strip_ your replies, especially if you reply to a digest. Also, could you try to refrain from using html in your mails if you post to mailing lists? Perhaps you are unaware that your mails are forwarded and will be kept in mailboxes of dozens, hundreds or even thousands of people. It all adds up and you taking up 50k per mail for a single mail where others use just a few k isn't right. Please brush up on your netiquette before posting to mailing lists. Try searching your favourite search engine for "netiquette mailing list". Or read f.e. http://www.woodgate.org/FAQs/netiquette.html . (I know, that post is probably older than you are.) Regards, Leonard. -- mount -t life -o ro /dev/dna /genetic/research
participants (2)
-
Leonard den Ottolander.nl -
mahesh gajabar