- function invoice_perm()
- {
- return array('access content invoice');
- }
- function invoice_menu(
- {
- $items['invoice'] = array(
- 'title' => 'Invoice Entry',
- 'page callback' => 'invoice_editpage',
- 'access callback' =>'user_access',
- 'access arguments' => array('access content invoice'),
- 'type' => MENU_NORMAL_ITEM,
- );
- return $items;
- }
- function invoice_editpage()
- {
- $output = t('Invoice Entry Form.');
- // Return the HTML generated from the $form data structure.
- $output .= drupal_get_form('invoice_nameform');
- return $output;
- }
- function invoice_nameform($form_id, $form_state = NULL)
- {
-
- //File Refernce name
- $form['invoice_title'] = array(
- '#type' => 'textfield',
- '#title'=>t('Invoice Title'),
- '#size'=>20,
- );
- $form['#attributes'] = array('enctype' => "multipart/form-data");
- $form['invoicefileattachment'] = array(
- '#type' => 'file',
- '#title' => t('Browse the Scan copy of the invoice'),
- '#required' => FALSE,
- '#size'=>20,
- '#default_value' => $form_state['values']['invoicefileattachment'],
- );
- $form['submit1'] = array(
- '#type' => 'submit',
- '#value' => t('Register'),
- );
- return $form;
- }
- function invoice_nameform_submit($form_id, $form_state)
- {
- global $user;
- profile_load_profile($user);
- $uid=$user->uid;
- $empid=$user->employee_code;
- $userip = $_SERVER['REMOTE_ADDR'];
- $dt=date('Y-m-d H:i:s');
- $state_code=$user->state_code;
- if($state_code==30)
- $abc='TR';
- else
- $abc='TN';
- $limits = array () ;
- $invoice_title = $form_state['values']['invoice_title'];
- $po_title=$form_state['values']['po_title'];
- $path123=file_directory_path();
- $file = file_save_upload('invoicefileattachment', $validators, file_directory_path());
- $filename = $file->filename;
- $src = file_directory_path() . '/' . $filename;
- $dest = $abc.'/'.$filename;
- $path_file=$path123.'/'.$abc.'/'.$filename;
- if(isset($filename))
- {
- file_copy($src, $dest, FILE_EXISTS_REPLACE);
- file_delete($path123.'/'.$filename);
- drupal_set_message (" Invoice File saved", "status");
- file_set_status ($file, FILE_STATUS_PERMANENT);
- db_query("INSERT into drupal_txn_file_upload(uid ,
- filename,
- filepath,
- filesize,
- state_code,
- category,
- timestamp,title)
- VALUES('%d','%s','%s','%d','%d','%s','%d','%s')",$uid,$filename,$path_file,$file_size,$state_code,$category,time(),$invoice_title);
- }
This site will provide lot of information for all the internet users with details of shortcut techniques and many more........
Saturday, January 29, 2011
Uploading Files in Drupal
Simple Form in Drupal
- function transport_services_perm() // used for setting permission
- {
- return array('access content transport_services');
- }
- function transport_services_menu() // creating menu
- {
- $items['transport_services'] = array(
- 'page callback' => 'transport_services_page',
- 'access arguments' => array('access content transport_services'),
- 'access callback' =>'user_access',
- ); return $items;
- }
- function transport_services_page()
- {
- $output='Welcome to R';
- $output .= drupal_get_form('transport_services_form1');
- return $output;
- }
- // Actual form being defined here....
- function transport_services_form2($form_id, $form_state = NULL)
- {
- $form['reg_no'] = array(
- '#title' => t('Registration Number:'),
- '#type' => 'textfield',
- '#size' => '25',
- '#required' => TRUE,
- '#prefix' => '',
- '#suffix' => '',
- );
- $form['reg_name'] = array(
- '#title' => t('Registration Name:'),
- '#type' => 'textfield',
- '#size' => '25',
- '#required' => TRUE,
- '#prefix' => '',
- '#suffix' => '',
- );
- $form['submit'] = array(
- '#type' => 'button',
- '#value' => t('Submit'),
- '#validate' => array('transport_services_renewal_output')
- );
- return $form;
- }
- // Submit Function is defined....
- function reusable_services_form1_submit($form_id,$form_state)
- {
- $reg_no = $form_state['values']['reg_no'];
- $reg_name = $form_state['values']['reg_name'];
- db_query("INSERT INTO {registration} (registration_no) VALUES('%d','%s')",$reg_no,$reg_name);
- drupal_set_message(t(“No==>”.$reg_no));
- drupal_set_message(t(“Name==>”.$reg_name));
- drupal_set_message(t(“Successfully inserted values”));
- }
Subscribe to:
Posts (Atom)