Re: creating pop-up window for delete and edit actions in table in module file<br><br>Hi Carl and Amit,<br>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.<br>
<br> Mahesh Gajabar<br><br><div class="gmail_quote">On Wed, Jan 12, 2011 at 12:44 PM, <span dir="ltr"><<a href="mailto:development-request@drupal.org">development-request@drupal.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Send development mailing list submissions to<br>
<a href="mailto:development@drupal.org">development@drupal.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.drupal.org/mailman/listinfo/development" target="_blank">http://lists.drupal.org/mailman/listinfo/development</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:development-request@drupal.org">development-request@drupal.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:development-owner@drupal.org">development-owner@drupal.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of development digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: creating pop-up window for delete and edit actions in<br>
table in module file (Carl Wiedemann)<br>
2. Re: creating pop-up window for delete and edit actions in<br>
table in module file (Amit Vyas)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 12 Jan 2011 00:05:48 -0700<br>
From: Carl Wiedemann <<a href="mailto:carl.wiedemann@gmail.com">carl.wiedemann@gmail.com</a>><br>
Subject: Re: [development] creating pop-up window for delete and edit<br>
actions in table in module file<br>
To: <a href="mailto:development@drupal.org">development@drupal.org</a><br>
Message-ID:<br>
<<a href="mailto:AANLkTikkSpGW3ex4JKq8q3QVtS4AzAFVe1ZAhJZG-74D@mail.gmail.com">AANLkTikkSpGW3ex4JKq8q3QVtS4AzAFVe1ZAhJZG-74D@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Consider <a href="http://drupal.org/project/popups" target="_blank">http://drupal.org/project/popups</a><br>
<br>
On Tue, Jan 11, 2011 at 11:37 PM, mahesh gajabar <<a href="mailto:mahesh143an@gmail.com">mahesh143an@gmail.com</a>>wrote:<br>
<br>
> Hi,<br>
><br>
> I have written a custome module table for showing some information which is<br>
> fetched from database and every row is having edit and delete actions. Both<br>
> are working fine. But whenever I click on on edit or delete action action it<br>
> opens in other window leaving current page. I want these actions to be taken<br>
> place in pop-up window.<br>
><br>
> My table on drupal screen is as follows<br>
><br>
> *SlNo*<br>
><br>
> *Doctor Name*<br>
><br>
> *Gender*<br>
><br>
> *Status*<br>
><br>
> *Action*<br>
><br>
> 2<br>
><br>
> Jayaram Srinivasan<br>
><br>
> male<br>
><br>
> inactive<br>
><br>
> Edit <<a href="http://localhost/fr/doctor/edit/2" target="_blank">http://localhost/fr/doctor/edit/2</a>> | Delete<<a href="http://localhost/fr/doctor/delete/2" target="_blank">http://localhost/fr/doctor/delete/2</a>><br>
><br>
> 3<br>
><br>
> Pavithra M<br>
><br>
> female<br>
><br>
> active<br>
><br>
> Edit <<a href="http://localhost/fr/doctor/edit/3" target="_blank">http://localhost/fr/doctor/edit/3</a>> | Delete<<a href="http://localhost/fr/doctor/delete/3" target="_blank">http://localhost/fr/doctor/delete/3</a>><br>
><br>
> 4<br>
><br>
> Ravi Mandayam<br>
><br>
> male<br>
><br>
> active<br>
><br>
> Edit <<a href="http://localhost/fr/doctor/edit/4" target="_blank">http://localhost/fr/doctor/edit/4</a>> | Delete<<a href="http://localhost/fr/doctor/delete/4" target="_blank">http://localhost/fr/doctor/delete/4</a>><br>
><br>
> when i click delete button i should get pop-up window with the dialogue<br>
> like this;<br>
><br>
> Are You Sure You Want To Delete This Doctor? This action cannot be undone.<br>
> Cancel <<a href="http://localhost/fr/doctor" target="_blank">http://localhost/fr/doctor</a>><br>
><br>
> When I click edit button I should get my edit form,<br>
> First Name:<br>
> Last Name:<br>
> Gender:<br>
> male<br>
> female<br>
> Status:<br>
> active<br>
> inactive<br>
> Cancel <<a href="http://localhost/fr/doctor" target="_blank">http://localhost/fr/doctor</a>><br>
><br>
> complete code of my module file is as follows:<br>
><br>
> *<?php<br>
><br>
> function doctor_menu() {<br>
> $items = array();<br>
><br>
> $items['doctor'] = array(<br>
> 'title' => t('Doctors'),<br>
> 'page callback' =>'doctors_list',<br>
> 'access arguments' => array('access doctor'),<br>
> 'type' => MENU_NORMAL_ITEM,<br>
> );<br>
><br>
> $items['doctor/delete/%doctor_user'] = array(<br>
> 'title' => t('Delete doctor'),<br>
> 'page callback' => 'drupal_get_form',<br>
> 'page arguments' => array('doctor_delete_confirm', 2),<br>
> 'access arguments' => array('access doctor'),<br>
> 'type' => MENU_CALLBACK,<br>
> );<br>
> $items['doctor/edit/%doctor_user'] = array(<br>
> 'title' => t('Edit Form'),<br>
> 'page callback' => 'drupal_get_form',<br>
> 'page arguments' => array('doctor_edit_confirm', 2),<br>
> 'access arguments' => array('access doctor'),<br>
> 'type' => MENU_NORMAL_ITEM,<br>
> );<br>
> return $items;<br>
> }<br>
><br>
> function doctors_list() {<br>
> $header = array(t(Sl.No),t('Doctor Name'), t('Gender'), t('Status'),<br>
> t('Action'));<br>
><br>
> $query = "SELECT * FROM {doctor}";<br>
> $rs = db_query($query);<br>
><br>
> $row = array();<br>
><br>
> if ($rs) {<br>
> while ($data = db_fetch_object($rs)) {<br>
> $doctorid =<br>
> $data->doctorid;<br>
> $gender = $data->gender;<br>
> $status = $data->status ;<br>
> $row[] =<br>
> array($doctorid,stripslashes(ucwords($data->firstname)) . ' ' .<br>
> stripslashes(ucwords($data->lastname)), $gender, $status,<br>
> "<a href='doctor/edit/{$data->doctorid}'>" . t('Edit') . "</a><br>
> |<a href='doctor/delete/{$data->doctorid}'> ". t('Delete')."</a>" );<br>
> }<br>
> }<br>
><br>
> $str .= theme_table($header, $row);<br>
><br>
> return $str;<br>
> }<br>
> function doctor_user_load($doctorid) {<br>
> $query = "SELECT * FROM {doctor} WHERE doctorid = %d";<br>
> $rs = db_query($query, $doctorid);<br>
><br>
> if ($rs) {<br>
> while ($data = db_fetch_object($rs)) {<br>
> return $data;<br>
> }<br>
> }<br>
><br>
> return FALSE;<br>
> }<br>
><br>
> function popup()<br>
> {<br>
> window.confirm();<br>
> return false;<br>
> }<br>
><br>
> function doctor_delete_confirm(&$form_state, $doctor) {<br>
> $form['_doctor'] = array(<br>
> '#type' => 'value',<br>
> '#value' => $doctor,<br>
> );<br>
><br>
> return confirm_form($form,<br>
> t('Are you sure you want to delete this doctor?'),<br>
> isset($_GET['destination']) ? $_GET['destination'] : "doctor",<br>
> t('This action cannot be undone.'),<br>
> t('Delete'),<br>
> t('Cancel'));<br>
> }<br>
><br>
> function doctor_delete_confirm_submit($form, &$form_state) {<br>
> $form_values = $form_state['values'];<br>
><br>
> if ($form_state['values']['confirm']) {<br>
> $doctor = $form_state['values']['_doctor'];<br>
><br>
> $query = "DELETE FROM {doctor} where<br>
> doctorid= $doctor->doctorid";<br>
> $rs = db_query($query);<br>
> drupal_set_message(t('Doctor has been deleted successfully.'));<br>
> } drupal_goto("doctor");<br>
> }<br>
><br>
> function doctor_edit_confirm(&$form_state,$doctor){<br>
> $form = array();<br>
> $form['_doctors'] = array(<br>
> '#type' => 'value',<br>
> '#value' => $doctor,<br>
> );<br>
><br>
> $query = "SELECT * FROM {doctor} where doctorid=%d";<br>
> $rs = db_query($query,$doctor->doctorid);<br>
> $data=db_fetch_object($rs);<br>
> $firstname=$data->firstname;<br>
> $lastname=$data->lastname;<br>
> $gender1 = $data->gender;<br>
> $gender = $gender1 ? 0: 1;<br>
> $status1 = $data->status ;<br>
> $status = $status1 ? 1: 0;<br>
> $form['firstname']=array(<br>
> '#title'=>t('First Name'),<br>
> '#type'=>'textfield',<br>
> '#default_value'=>$data->firstname,<br>
><br>
> );<br>
> $form['lastname']=array(<br>
> '#title'=>t('Last Name'),<br>
> '#type'=>'textfield',<br>
> '#default_value' => $lastname,<br>
> );<br>
> $form['gender']=array(<br>
> '#title'=>t('Gender'),<br>
> '#type'=>'radios',<br>
><br>
> '#options' => array(t('male'),<br>
> t('female')),<br>
> '#default_value' =><br>
> variable_get('gender',$gender),<br>
> );<br>
> $form['status']=array(<br>
> '#title'=>t('Status'),<br>
> '#type'=>'radios',<br>
> '#options' => array(t('active'),<br>
> t('inactive')),<br>
> '#default_value' =><br>
> variable_get('status',$status),<br>
><br>
> );<br>
><br>
> return confirm_form($form,t(''),<br>
> isset($_GET['destination']) ? $_GET['destination'] : "doctor",<br>
> t(''),<br>
> t('Save'),<br>
> t('Cancel'));<br>
> }<br>
><br>
> function doctor_edit_confirm_submit($form, &$form_state)<br>
> {<br>
> if ($form_state['values']['confirm']) {<br>
> $doctor = $form_state['values']['_doctors'];<br>
> $form_state['values']['doctorid'] = $doctor->doctorid;<br>
> $firstname = $form_state['values']['firstname'];<br>
> $lastname = $form_state['values']['lastname'];<br>
> $gender1= $form_state['values']['gender'];<br>
> $gender = $gender1 ? t('female') : t('male');<br>
> $status1 = $form_state['values']['status'];<br>
> $status = $status1 ? t('inactive') : t('active');<br>
> $query = "UPDATE {doctor} SET firstname = '$firstname', lastname=<br>
> '$lastname', gender = '$gender', status = '$status' WHERE doctorid=%d";<br>
> $rs = db_query($query,$doctor->doctorid); }<br>
> drupal_goto("doctor");<br>
> }<br>
><br>
> *Any help appreciated.*<br>
><br>
> *<br>
> *Regards,*<br>
> Mahesh Gajabar<br>
><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.drupal.org/pipermail/development/attachments/20110112/630ba1d0/attachment-0001.html" target="_blank">http://lists.drupal.org/pipermail/development/attachments/20110112/630ba1d0/attachment-0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 12 Jan 2011 12:43:53 +0530<br>
From: Amit Vyas <<a href="mailto:vyasamit2007@gmail.com">vyasamit2007@gmail.com</a>><br>
Subject: Re: [development] creating pop-up window for delete and edit<br>
actions in table in module file<br>
To: <a href="mailto:development@drupal.org">development@drupal.org</a><br>
Message-ID:<br>
<<a href="mailto:AANLkTimtc_Jn07npqqoDMyuyGpSs4JyzXFiVunWHoKo3@mail.gmail.com">AANLkTimtc_Jn07npqqoDMyuyGpSs4JyzXFiVunWHoKo3@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Popups is what you want :-)<br>
<br>
On Wed, Jan 12, 2011 at 12:35 PM, Carl Wiedemann<br>
<<a href="mailto:carl.wiedemann@gmail.com">carl.wiedemann@gmail.com</a>>wrote:<br>
<br>
> Consider <a href="http://drupal.org/project/popups" target="_blank">http://drupal.org/project/popups</a><br>
><br>
><br>
> On Tue, Jan 11, 2011 at 11:37 PM, mahesh gajabar <<a href="mailto:mahesh143an@gmail.com">mahesh143an@gmail.com</a>>wrote:<br>
><br>
>> Hi,<br>
>><br>
>> I have written a custome module table for showing some information which<br>
>> is fetched from database and every row is having edit and delete actions.<br>
>> Both are working fine. But whenever I click on on edit or delete action<br>
>> action it opens in other window leaving current page. I want these actions<br>
>> to be taken place in pop-up window.<br>
>><br>
>> My table on drupal screen is as follows<br>
>><br>
>> *SlNo*<br>
>><br>
>> *Doctor Name*<br>
>><br>
>> *Gender*<br>
>><br>
>> *Status*<br>
>><br>
>> *Action*<br>
>><br>
>> 2<br>
>><br>
>> Jayaram Srinivasan<br>
>><br>
>> male<br>
>><br>
>> inactive<br>
>><br>
>> Edit <<a href="http://localhost/fr/doctor/edit/2" target="_blank">http://localhost/fr/doctor/edit/2</a>> | Delete<<a href="http://localhost/fr/doctor/delete/2" target="_blank">http://localhost/fr/doctor/delete/2</a>><br>
>><br>
>> 3<br>
>><br>
>> Pavithra M<br>
>><br>
>> female<br>
>><br>
>> active<br>
>><br>
>> Edit <<a href="http://localhost/fr/doctor/edit/3" target="_blank">http://localhost/fr/doctor/edit/3</a>> | Delete<<a href="http://localhost/fr/doctor/delete/3" target="_blank">http://localhost/fr/doctor/delete/3</a>><br>
>><br>
>> 4<br>
>><br>
>> Ravi Mandayam<br>
>><br>
>> male<br>
>><br>
>> active<br>
>><br>
>> Edit <<a href="http://localhost/fr/doctor/edit/4" target="_blank">http://localhost/fr/doctor/edit/4</a>> | Delete<<a href="http://localhost/fr/doctor/delete/4" target="_blank">http://localhost/fr/doctor/delete/4</a>><br>
>><br>
>> when i click delete button i should get pop-up window with the dialogue<br>
>> like this;<br>
>><br>
>> Are You Sure You Want To Delete This Doctor? This action cannot be<br>
>> undone.<br>
>> Cancel <<a href="http://localhost/fr/doctor" target="_blank">http://localhost/fr/doctor</a>><br>
>><br>
>> When I click edit button I should get my edit form,<br>
>> First Name:<br>
>> Last Name:<br>
>> Gender:<br>
>> male<br>
>> female<br>
>> Status:<br>
>> active<br>
>> inactive<br>
>> Cancel <<a href="http://localhost/fr/doctor" target="_blank">http://localhost/fr/doctor</a>><br>
>><br>
>> complete code of my module file is as follows:<br>
>><br>
>> *<?php<br>
>><br>
>> function doctor_menu() {<br>
>> $items = array();<br>
>><br>
>> $items['doctor'] = array(<br>
>> 'title' => t('Doctors'),<br>
>> 'page callback' =>'doctors_list',<br>
>> 'access arguments' => array('access doctor'),<br>
>> 'type' => MENU_NORMAL_ITEM,<br>
>> );<br>
>><br>
>> $items['doctor/delete/%doctor_user'] = array(<br>
>> 'title' => t('Delete doctor'),<br>
>> 'page callback' => 'drupal_get_form',<br>
>> 'page arguments' => array('doctor_delete_confirm', 2),<br>
>> 'access arguments' => array('access doctor'),<br>
>> 'type' => MENU_CALLBACK,<br>
>> );<br>
>> $items['doctor/edit/%doctor_user'] = array(<br>
>> 'title' => t('Edit Form'),<br>
>> 'page callback' => 'drupal_get_form',<br>
>> 'page arguments' => array('doctor_edit_confirm', 2),<br>
>> 'access arguments' => array('access doctor'),<br>
>> 'type' => MENU_NORMAL_ITEM,<br>
>> );<br>
>> return $items;<br>
>> }<br>
>><br>
>> function doctors_list() {<br>
>> $header = array(t(Sl.No),t('Doctor Name'), t('Gender'), t('Status'),<br>
>> t('Action'));<br>
>><br>
>> $query = "SELECT * FROM {doctor}";<br>
>> $rs = db_query($query);<br>
>><br>
>> $row = array();<br>
>><br>
>> if ($rs) {<br>
>> while ($data = db_fetch_object($rs)) {<br>
>> $doctorid =<br>
>> $data->doctorid;<br>
>> $gender = $data->gender;<br>
>> $status = $data->status ;<br>
>> $row[] =<br>
>> array($doctorid,stripslashes(ucwords($data->firstname)) . ' ' .<br>
>> stripslashes(ucwords($data->lastname)), $gender, $status,<br>
>> "<a href='doctor/edit/{$data->doctorid}'>" . t('Edit') .<br>
>> "</a> |<a href='doctor/delete/{$data->doctorid}'> ". t('Delete')."</a>" );<br>
>> }<br>
>> }<br>
>><br>
>> $str .= theme_table($header, $row);<br>
>><br>
>> return $str;<br>
>> }<br>
>> function doctor_user_load($doctorid) {<br>
>> $query = "SELECT * FROM {doctor} WHERE doctorid = %d";<br>
>> $rs = db_query($query, $doctorid);<br>
>><br>
>> if ($rs) {<br>
>> while ($data = db_fetch_object($rs)) {<br>
>> return $data;<br>
>> }<br>
>> }<br>
>><br>
>> return FALSE;<br>
>> }<br>
>><br>
>> function popup()<br>
>> {<br>
>> window.confirm();<br>
>> return false;<br>
>> }<br>
>><br>
>> function doctor_delete_confirm(&$form_state, $doctor) {<br>
>> $form['_doctor'] = array(<br>
>> '#type' => 'value',<br>
>> '#value' => $doctor,<br>
>> );<br>
>><br>
>> return confirm_form($form,<br>
>> t('Are you sure you want to delete this doctor?'),<br>
>> isset($_GET['destination']) ? $_GET['destination'] : "doctor",<br>
>> t('This action cannot be undone.'),<br>
>> t('Delete'),<br>
>> t('Cancel'));<br>
>> }<br>
>><br>
>> function doctor_delete_confirm_submit($form, &$form_state) {<br>
>> $form_values = $form_state['values'];<br>
>><br>
>> if ($form_state['values']['confirm']) {<br>
>> $doctor = $form_state['values']['_doctor'];<br>
>><br>
>> $query = "DELETE FROM {doctor} where<br>
>> doctorid= $doctor->doctorid";<br>
>> $rs = db_query($query);<br>
>> drupal_set_message(t('Doctor has been deleted successfully.'));<br>
>> } drupal_goto("doctor");<br>
>> }<br>
>><br>
>> function doctor_edit_confirm(&$form_state,$doctor){<br>
>> $form = array();<br>
>> $form['_doctors'] = array(<br>
>> '#type' => 'value',<br>
>> '#value' => $doctor,<br>
>> );<br>
>><br>
>> $query = "SELECT * FROM {doctor} where doctorid=%d";<br>
>> $rs = db_query($query,$doctor->doctorid);<br>
>> $data=db_fetch_object($rs);<br>
>> $firstname=$data->firstname;<br>
>> $lastname=$data->lastname;<br>
>> $gender1 = $data->gender;<br>
>> $gender = $gender1 ? 0: 1;<br>
>> $status1 = $data->status ;<br>
>> $status = $status1 ? 1: 0;<br>
>> $form['firstname']=array(<br>
>> '#title'=>t('First Name'),<br>
>> '#type'=>'textfield',<br>
>> '#default_value'=>$data->firstname,<br>
>><br>
>> );<br>
>> $form['lastname']=array(<br>
>> '#title'=>t('Last Name'),<br>
>> '#type'=>'textfield',<br>
>> '#default_value' => $lastname,<br>
>> );<br>
>> $form['gender']=array(<br>
>> '#title'=>t('Gender'),<br>
>> '#type'=>'radios',<br>
>><br>
>> '#options' => array(t('male'),<br>
>> t('female')),<br>
>> '#default_value' =><br>
>> variable_get('gender',$gender),<br>
>> );<br>
>> $form['status']=array(<br>
>> '#title'=>t('Status'),<br>
>> '#type'=>'radios',<br>
>> '#options' => array(t('active'),<br>
>> t('inactive')),<br>
>> '#default_value' =><br>
>> variable_get('status',$status),<br>
>><br>
>> );<br>
>><br>
>> return confirm_form($form,t(''),<br>
>> isset($_GET['destination']) ? $_GET['destination'] : "doctor",<br>
>> t(''),<br>
>> t('Save'),<br>
>> t('Cancel'));<br>
>> }<br>
>><br>
>> function doctor_edit_confirm_submit($form, &$form_state)<br>
>> {<br>
>> if ($form_state['values']['confirm']) {<br>
>> $doctor = $form_state['values']['_doctors'];<br>
>> $form_state['values']['doctorid'] = $doctor->doctorid;<br>
>> $firstname = $form_state['values']['firstname'];<br>
>> $lastname = $form_state['values']['lastname'];<br>
>> $gender1= $form_state['values']['gender'];<br>
>> $gender = $gender1 ? t('female') : t('male');<br>
>> $status1 = $form_state['values']['status'];<br>
>> $status = $status1 ? t('inactive') : t('active');<br>
>> $query = "UPDATE {doctor} SET firstname = '$firstname', lastname=<br>
>> '$lastname', gender = '$gender', status = '$status' WHERE doctorid=%d";<br>
>> $rs = db_query($query,$doctor->doctorid); }<br>
>> drupal_goto("doctor");<br>
>> }<br>
>><br>
>> *Any help appreciated.*<br>
>><br>
>> *<br>
>> *Regards,*<br>
>> Mahesh Gajabar<br>
>><br>
>><br>
><br>
<br>
<br>
--<br>
Cheers,<br>
Amit Vyas<br>
____________________________________________________________________<br>
Email : <a href="mailto:amit.vyas@blisstering.com">amit.vyas@blisstering.com</a> Skype : vyasamit2004<br>
Mobile : +91 993-040-1490 Phone : +91-022<br>
428-884-07<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.drupal.org/pipermail/development/attachments/20110112/7e5bc696/attachment.html" target="_blank">http://lists.drupal.org/pipermail/development/attachments/20110112/7e5bc696/attachment.html</a><br>
<br>
------------------------------<br>
<font color="#888888"><br>
--<br>
[ Drupal development list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
<br>
End of development Digest, Vol 97, Issue 27<br>
*******************************************<br>
</font></blockquote></div><br>