DrupalCustom

fucn

Jun 29th, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.45 KB | None | 0 0
  1. function create_freeway_project() {
  2.   drupal_add_js(drupal_get_path('module', 'freeway') . '/js/dashboardscript.js');
  3.   //date_popup_load();
  4.   $node = node_load(arg(1));
  5.   $form = array();
  6.  
  7.   $arrayForSendTranslation = array();
  8.   $arrayForSendTranslation = credentialProvider();
  9.   $finalFunctionUserName = $arrayForSendTranslation[0];
  10.   $finalFunctionPassword = $arrayForSendTranslation[1];
  11.  
  12. $parts = parse_ini_file('sites/all/modules/freeway/urlconfig.ini');
  13.  
  14.  
  15. $LoginClient = new SoapClient($parts['part1'], array("trace" => 1));
  16. $ServicesLink = new SoapClient($parts['part2'], array("trace" => 1));
  17.  
  18.   try {
  19.     $arrResponse = $LoginClient->Logon(array('Username' => $finalFunctionUserName, 'Password' => $finalFunctionPassword));
  20.     $ticket = ($arrResponse->LogonResult);
  21.  
  22.     $custAnalysis = $ServicesLink->GetCustomerAnalysisCodes(array('Ticket' => $ticket, 'AnalysisCodeLabel' => ''));
  23.  
  24.  
  25.     $analysisNames = array();
  26.     $analysisCodeOne = array();
  27.     $analysisCodeTwo = array();
  28.  
  29.  
  30.     foreach ($custAnalysis->GetCustomerAnalysisCodesResult->AnalysisCodeGroup as $acode) {
  31.       $analysisNames[] = $acode->Name;
  32.     }
  33.     for ($i = 0; $i < count($analysisNames) -1; $i += 1) {
  34.  
  35.       $custAnalysisInner = $ServicesLink->GetCustomerAnalysisCodes(array('Ticket' => $ticket, 'AnalysisCodeLabel' => $analysisNames[$i]));
  36.  
  37.  
  38.       foreach ($custAnalysisInner->GetCustomerAnalysisCodesResult->AnalysisCodeGroup->AnalysisCodes->AnalysisCode as $acodes) {
  39.  
  40.         if ($i == 0) {
  41.           $codeOne = $acodes->Name;
  42.           $analysisCodeOne[] = $codeOne;
  43.         }
  44.         if ($i == 1) {
  45.           $codeTwo = $acodes->Name;
  46.           $analysisCodeTwo[] = substr($codeTwo, 1 );
  47.         }
  48.  
  49.       }
  50.  
  51.  
  52.     }
  53.  
  54.   }
  55.  
  56.   catch (SoapFault $exception) {
  57.     drupal_get_messages();
  58.     drupal_set_message("The following exception took place." . $exception . "Kindly check Freeway mapping");
  59.     drupal_goto("user");
  60.  
  61.   }
  62.  
  63.  
  64.   $defaultRef = 'My Reference';
  65.  
  66.   $form['title'] = array(
  67.     '#type' => 'textfield',
  68.     '#title' => t('Project Description'),
  69.     '#size' => 60,
  70.     '#maxlength' => 30,
  71.     '#required' => TRUE,
  72.   );
  73.  
  74.   $form['custRef'] = array(
  75.     '#type' => 'textfield',
  76.     '#title' => t('Customer Reference'),
  77.     '#default_value' => $defaultRef,
  78.     '#size' => 60,
  79.     '#maxlength' => 30,
  80.     '#required' => FALSE,
  81.   );
  82.  
  83.   $form['poRef'] = array(
  84.     '#type' => 'textfield',
  85.     '#title' => t('PO Reference'),
  86.     '#size' => 60,
  87.     '#maxlength' => 30,
  88.     '#required' => FALSE,
  89.   );
  90.  
  91.  
  92.   $form['splinst'] = array(
  93.     '#type' => 'textarea',
  94.     '#title' => t('Special Instructions'),
  95.     '#size' => 60,
  96.     '#maxlength' => 100,
  97.     '#required' => FALSE,
  98.   );
  99.  
  100.  
  101. /*
  102. $form['enddate'] = array(
  103.   '#type' => 'date_popup',
  104.   '#title' => t('Delivery Date'),
  105.   '#size' => 60,
  106.   '#maxlength' => 128,
  107.   '#required' => TRUE,
  108.   '#date_format' => 'm/d/Y'
  109.   // With this format you'll get a date popup box AND a time widget. Obviously you can change this to whatever you need.
  110. );
  111. */
  112.  
  113. $form['enddate'] = array(
  114.     '#type' => 'date_select',
  115.     '#title' => t('Delivery Date:'),
  116.     '#date_format' => 'd-m-Y',
  117.     '#default_value' => $enddate,
  118.     '#date_year_range' => '0:+10',
  119.     '#required' => TRUE,
  120.     '#date_label_position' => 'within'
  121.  );
  122.  
  123.  
  124.  
  125.   $form['create_project_btn'] = array(
  126.     '#type' => 'submit',
  127.     '#value' => 'Create Freeway Project',
  128.     '#weight' => 10,
  129.   );
  130.  
  131.  
  132.   return $form;
  133.  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment