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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110112/630ba1d0/attachment-0001.html

------------------------------

Message: 2
Date: Wed, 12 Jan 2011 12:43:53 +0530
From: Amit Vyas <vyasamit2007@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:
       <AANLkTimtc_Jn07npqqoDMyuyGpSs4JyzXFiVunWHoKo3@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Popups is what you want :-)

On Wed, Jan 12, 2011 at 12:35 PM, Carl Wiedemann
<carl.wiedemann@gmail.com>wrote:

> 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
>>
>>
>


--
Cheers,
Amit Vyas
____________________________________________________________________
Email  : amit.vyas@blisstering.com               Skype : vyasamit2004
Mobile : +91 993-040-1490                          Phone : +91-022
428-884-07
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110112/7e5bc696/attachment.html

------------------------------

--
[ Drupal development list | http://lists.drupal.org/ ]

End of development Digest, Vol 97, Issue 27
*******************************************