Esempio n. 1
0
function get_deal_params() {
  
  // Get global params
  $params = get_global_params('Deal');
  
  // Get deal specific params
  // sel_tt
  if (is_array($params['tt'])) {
    while ( list( $key, $value ) = each( $params['tt'] ) ) {
      // sel_tt contains select infos (data-tt-$id)
      if (strcmp(substr($value, 0, 8),'data-tt-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['tasktype'][] = $id;
      } else {
        // sel_tt contains ids
        $params['tasktype'][] = $value;
      } 
    }
  }

  // Handle DealCompany infos
  $cpt = 0;
  while (isset($params["data_dc_$cpt"])) {
    $dccid = $params["data_dccid_$cpt"];
    $dccname = $params["data_dccname_$cpt"];
    $dccnewid = $params["data_dccnewid_$cpt"];
    $dccnewname = $params["data_dccnewname_$cpt"];
    $dcroleid = $params["role$cpt"];

    if ($dccnewid > 0) {
      $params['dc'][$cpt]['company_id'] = $dccnewid;
      $params['dc'][$cpt]['company_name'] = $dccnewname;
      $params['dc'][$cpt]['role_id'] = $dcroleid;
    } else if ($dccid > 0) {
      $params['dc'][$cpt]['company_id'] = $dccid;
      $params['dc'][$cpt]['company_name'] = $dccname;
      $params['dc'][$cpt]['role_id'] = $dcroleid;
    }
    $cpt++;
  }

  $params['order'] = (isset($params['order']) ? $params['order'] : '0');
  
  get_global_params_document($params);
  
  return $params;
}
Esempio n. 2
0
function get_calendar_params() {
  global $ccalendar_first_hour, $ccalendar_last_hour, $obm;

  // Get global params
  $params = get_global_params('Entity');
  
  // Get calendar specific params
  if ($params['group_view'] == '') {
    $params['group_view'] = $params['group_id'];
  }
  //FIXME
  $params['date'] = of_isodate_convert($params['date']);
  $params['date'] = new Of_Date($params['date']);
  $params['repeat_end'] = of_isodate_convert($params['repeat_end'],true);
  if(!is_null($params['repeat_end'])) {
    $params['repeat_end'] = new Of_Date($params['repeat_end']);
  }
  $params['event_before_date'] = of_isodate_convert($params['event_before_date']);
  if(!is_null($params['event_before_date'])) {
    $params['event_before_date'] = new Of_Date($params['event_before_date']);
  }
  $params['date_begin'] = of_isodate_convert($params['date_begin'],true);
  if(!is_null($params['date_begin'])) {
    $params['date_begin'] = new Of_Date($params['date_begin']);
  }
  $params['date_end'] = of_isodate_convert($params['date_end'],true);
  if(!is_null($params['date_end'])) {
    $params['date_end'] = new Of_Date($params['date_end']);
  }
  $params['old_date_begin'] = of_isodate_convert($params['old_date_begin'],true);
  if(!is_null($params['old_date_begin'])) {
    $params['old_date_begin'] = new Of_Date($params['old_date_begin']);
  }  
  if (isset($params['time_begin']) && !is_null($params['date_begin'])) {
    $params['date_begin']->setHour($params['time_begin']);
    $params['date_begin']->setMinute($params['min_begin']);
  }
  if (isset($params['time_end']) &&  !is_null($params['date_end'])) {
    $params['date_end']->setHour($params['time_end']);
    $params['date_end']->setMinute($params['min_end']);

    if(!is_null($params['repeat_end'])) {
      # Don't remove the two lines below. The side effect is that this sets the
      # end date right.
      $params['repeat_end']->setHour($params['time_end']);
      $params['repeat_end']->setMinute($params['min_end']);
    }
  } elseif(!is_null($params['date_end'])) {
    $params['date_end']->setHour($ccalendar_last_hour);
  }
  // New meeting event duration
  if (isset($params['time_duration'])) {
    $params['meeting_duration'] = $params['time_duration'] * 3600;
    if (isset($params['min_duration'])) {
      $params['meeting_duration'] += $params['min_duration'] * 60;
    } 
  }
  if (!is_null($params['date_end']) && !is_null($params['date_begin'])) {
    $params['event_duration'] = $params['date_end']->diffTimestamp($params['date_begin']);
    if($params['event_duration'] <= 0) {
      $params['event_duration'] = 0;
    }
  } else {
    $params['event_duration'] = 0;
  }
  if (!is_null($params['date_begin']) && is_null($params['date_end']) && isset($params['duration'])) {
    $clone = clone $params['date_begin'];
    $params['date_end'] = $clone->addSecond($params['duration']);
  } 
  if (is_array($params['date_exception'])) {
    $exceptions = array_unique($params['date_exception']);
    $params['date_exception'] = array();
    foreach($exceptions as $key => $exception) {
      if(trim($exception) != '') {
        $exception = of_isodate_convert($exception);
        $params['date_exception'][$key] = new Of_Date($exception);
      }
    }
  }
  // repeat days
  for ($i=0; $i<7; $i++) {
    if (isset($params["repeatday_$i"])) {
      $params['repeat_days'] .= '1';
    } else {
      $params['repeat_days'] .= '0';
    }
  }

  if ($params['owner']=='') {
    $params['owner'] = $obm['uid'];
  } else {
    if (strcmp(substr($params['owner'], 0, 10),'data-user-') == 0) {
      $data = explode('-', $params['owner']);
      $params['owner'] = $data[2];
    }
  }

  if ($params['organizer']=='') {
    $params['organizer'] = $obm['uid'];
  }

  // sel_group_id can be filled by sel_group_id
  if (is_array($params['group_id'])) {
    while (list($key, $value) = each($params['group_id']) ) {
      // sel_group_id contains select infos (data-group-$id)
      if (strcmp(substr($value, 0, 11),'data-group-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['sel_group_id'][] = $id;
      } else {
        // direct id
        $params['sel_group_id'][] = $value;
      }
    }
  }

  // sel_user_id can be filled by sel_user_id or sel_ent (see below)
  if (is_array($params['user_id'])) {
    while (list($key, $value) = each($params['user_id'])) {
      // sel_user_id contains select infos (data-user-$id)
      if (strcmp(substr($value, 0, 10),'data-user-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['sel_user_id'][] = $id;
      } else if (strcmp(substr($value, 0, 13),'data-contact-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['sel_contact_id'][] = $id;
      } else {
        // direct id
        $params['sel_user_id'][] = $value;
      }
    }
  }

  // sel_contact_id can be filled by sel_contact_id or sel_ent (see below)
  if (is_array($params['contact_id'])) {
    while (list($key, $value) = each($params['contact_id'])) {
      // sel_user_id contains select infos (data-user-$id)
      if (strcmp(substr($value, 0, 13),'data-contact-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['sel_contact_id'][] = $id;
      } else {
        // direct id
        $params['sel_contact_id'][] = $value;
      }
    }
  }


  // sel_resource_id can be filled by sel_resource_id or sel_ent (see below)
  if (is_array($params['resource_id'])) {
    while (list($key, $value) = each($params['resource_id']) ) {
      // sel_resource_id contains select infos (data-resource-$id)
      if (strcmp(substr($value, 0, 14),'data-resource-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['sel_resource_id'][] = $id;
      } else {
        // direct id
        $params['sel_resource_id'][] = $value;
      }
    }
  }
  
  // sel_resource_id can be filled by sel_resource_id or sel_ent (see below)
  if (is_array($params['resource_group_id'])) {
    while (list($key, $value) = each($params['resource_group_id']) ) {
      // sel_resource_id contains select infos (data-resource-$id)
      if (strcmp(substr($value, 0, 19),'data-resourcegroup-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['sel_resource_group_id'][] = $id;
      } else {
        // direct id
        $params['sel_resource_group_id'][] = $value;
      }
    }
  }  
  
  if (is_array($params['document_id'])) {
    while (list($key, $value) = each($params['document_id']) ) {
      // sel_document_id contains select infos (data-document-$id)
      if (strcmp(substr($value, 0, 14),'data-document-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['sel_document_id'][] = $id;
      } else {
        // direct id
        $params['sel_document_id'][] = $value;
      }
    }
  }
  
  // feature params (user & resource)
  if (is_array($params['ent'])) {
    $nb_data = 0;
    $nb['user'] = 0;
    $nb['resource'] = 0;
    while(list($key,$value ) = each($params['ent'])) {
      if (strcmp(substr($value, 0, 5),'data-') == 0) {
        $nb_data++;
        $data = explode('-', $value);
        $ent = $data[1];
        $id = $data[2];
        $nb[$ent]++;
        $params["sel_${ent}_id"][] = $id;
      }
    }
  }

  // imported file
  if (isset ($_FILES['fi_ics'])) {
    $params['ics_tmp'] = $_FILES['fi_ics']['tmp_name'];
    $params['ics_name'] = $_FILES['fi_ics']['name'];
    $params['ics_size'] = $_FILES['fi_ics']['size'];
    $params['ics_type'] = $_FILES['fi_ics']['type'];
  }
  
  if (isset ($_FILES['fi_other_files'])) {
    $params['other_files'] = array();
    foreach ($_FILES['fi_other_files']['name'] as $k => $name) {
      if ($_FILES['fi_other_files']['error'][$k] !== UPLOAD_ERR_OK) {
        continue;
      }
      $params['other_files'][] = array(
        'file_tmp' => $_FILES['fi_other_files']['tmp_name'][$k],
        'name' => $_FILES['fi_other_files']['name'][$k],
        'size' => $_FILES['fi_other_files']['size'][$k],
        'type' => $_FILES['fi_other_files']['type'][$k],
      );
    }
  }

  if(is_array($params['others_attendees'])) {
    foreach($params['others_attendees'] as $mail) {
      if(trim($mail) != '') $others_attendees[] = trim($mail);
    }
    $params['others_attendees'] = $others_attendees;
  }
  
  get_global_params_document($params);
  return $params;
}
Esempio n. 3
0
function get_company_params() {

  // Get global params
  $params = get_global_params('Company');
  
  // Get company specific params
  if (isset ($params['name'])) $params['name'] = get_format_company_name($params['name']);
  if (isset ($params['town'])) $params['town'] = get_format_town($params['town']);
  
  get_global_params_document($params);

  return $params;
}
Esempio n. 4
0
function get_invoice_params() {

  // Get global params
  $params = get_global_params('Invoice');

  // Get Invoice specific params
  // sel_tt
  if (is_array($params['tt'])) {
    while ( list( $key, $value ) = each( $params['tt'] ) ) {
      // sel_tt contains select infos (data-tt-$id)
      if (strcmp(substr($value, 0, 8),'data-tt-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['tasktype'][] = $id;
      } else {
        // sel_tt contains ids
        $params['tasktype'][] = $value;
      } 
    }
  }
  
  get_global_params_document($params);
  
  return $params;
}
Esempio n. 5
0
function get_contact_params() {
  
  // Get global params
  $params = get_global_params('Contact');
  
  // Get contact specific params
  if (isset ($params['town'])) $params['town'] = get_format_town($params['town']);
  if ((isset ($params['entity_id'])) && (! isset($params['contact_id']))) {
    $params['contact_id'] = $params['entity_id'];
  }
  if(isset($params['contact_id'])) $params['id'] = $params['contact_id'];
  get_global_params_document($params);
  
  // imported file
  if (isset ($_FILES['vcard_file'])) {
    $params['vcard_tmp']  = $_FILES['vcard_file']['tmp_name'];
    $params['vcard_name'] = $_FILES['vcard_file']['name'];
    $params['vcard_size'] = $_FILES['vcard_file']['size'];
    $params['vcard_type'] = $_FILES['vcard_file']['type'];
  }

  return $params;
}
Esempio n. 6
0
function get_incident_params() {
  
  // Get global params
  $params = get_global_params("Incident");
  
  get_global_params_document($params);

  if (strcmp(substr($params['logger'], 0, 10),'data-user-') == 0) {
    $data = explode('-', $params['logger']);
    $params['logger'] = $data[2];
  }

  return $params;
}
Esempio n. 7
0
function get_contract_params() {
  
  // Get global params
  $params = get_global_params("Contract");
  
  // Get contract specific params
  $params["code"] = (isset($params["code"]) ? $params["code"] : "0");

  get_global_params_document($params);

  return $params;
}
Esempio n. 8
0
function get_project_params() {

  // Get global params
  $params = get_global_params('Project');

  // Get project specific params
  $nb_mem = 0;
  $nb_tsk = 0;

  /*  if (!isset ($params['date'])) {
    $params['date'] = date('Ymd'); 
  }
  */
  // Get project specific params
  
  foreach($params as $key => $value) {
    if (strcmp(substr($key, 0, 10),'data-task-') == 0) {
      $nb_tsk++;
      $tsk_num = substr($key, 10);
      $params["tsk$nb_tsk"] = $tsk_num;
    }
    else if (strcmp(substr($key, 0, 10),'data-user-') == 0) {
      $nb_mem++;
      $mem_num = substr($key, 10);
      $params["mem$nb_mem"] = $mem_num;
    } 
  }

  if (is_array($params['task_id'])) {
    foreach($params['task_id'] as $key => $value) {
      // sel_user_id contains select infos (data-user-$id)
      if (strcmp(substr($value, 0, 10),'data-task-') == 0) {
        $data = explode('-', $value);
        $id = $data[2];
        $params['reftask_id'][] = $id;
      } else {
        // direct id
        $params['reftask_id'][] = $value;
      }
    }
  }
  
  $params['mem_nb'] = $nb_mem;
  $params['tsk_nb'] = $nb_tsk;
  
  get_global_params_document($params);

  return $params;
}