Source for file cphplib_formular.inc

Documentation is available at cphplib_formular.inc

  1. <?php
  2. /**
  3. * Formular extention for cphplib
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * @category Utilities
  8. * @package cphplib
  9. * @author Alexander Meindl <am@community-loesungen.de>
  10. * @copyright (c) 2005 meindlSOFT
  11. * @license Released under v2 of the GNU LGPL
  12. * @version CVS: $Id: cphplib_formular.inc,v 1.10 2005/10/21 06:27:54 alex Exp $
  13. * @link http://www.meindlsoft.com/tools.php
  14. */
  15.  
  16. /**
  17. * cphplib formular extention
  18. */
  19. class cphplib_formular extends cphplib
  20. {
  21. /**
  22. * Show error messages with class
  23. *
  24. * @var bool true: show error fields with class
  25. * false: show non-error fields with class
  26. */
  27. var $err_mode = false;
  28.  
  29. /**
  30. * Formular error messages
  31. *
  32. * @var array
  33. */
  34. var $form_errors;
  35.  
  36. /**
  37. * Current client operating system
  38. *
  39. * @var char
  40. */
  41. var $os_type;
  42.  
  43. /**
  44. * Current browser type
  45. *
  46. * @var char
  47. */
  48. var $browser_type;
  49.  
  50. /**
  51. * Set name parameter of formular object
  52. *
  53. * @var bool
  54. */
  55. var $set_formular_name = true;
  56.  
  57. /**
  58. * Set id parameter of formular object
  59. *
  60. * @var bool
  61. */
  62. var $set_formular_id = false;
  63.  
  64. /**
  65. * Current formular name
  66. *
  67. * @var string
  68. */
  69. var $formular_name;
  70.  
  71. /**
  72. * CSS class for buttons in formular
  73. *
  74. * @var string
  75. */
  76. var $class_button = "button";
  77.  
  78. /**
  79. * CSS class for buttons in formular (for error displaying)
  80. *
  81. * @var string
  82. */
  83. var $class_shadow = "shadow";
  84.  
  85. /**
  86. * CSS class for valid input fileds (non-error displaying)
  87. *
  88. * @var string
  89. */
  90. var $class_non_error = "";
  91.  
  92. /**
  93. * CSS class for error messages (HEADER)
  94. *
  95. * @var string
  96. */
  97. var $class_error_header = "err_header";
  98.  
  99. /**
  100. * CSS class for error messages (BODY)
  101. *
  102. * @var string
  103. */
  104. var $class_error_body = "err";
  105.  
  106. /**
  107. * Default date view mode: M = month
  108. * Q = quarter
  109. * Y = year
  110. *
  111. * @var string
  112. */
  113. var $default_date_period = "M";
  114.  
  115. /**
  116. * First year in date select box
  117. *
  118. * @var int
  119. */
  120. var $first_date_year = 1970;
  121.  
  122. /**
  123. * Color for error displaying (only used for opera!)
  124. *
  125. * @deprecated
  126. *
  127. * @var string
  128. */
  129. var $error_color = "grey"; // $STYLE['form2_bordercolor'];
  130.  
  131.  
  132. function cphplib_formular($locale="de_DE")
  133. {
  134. parent::cphplib($locale);
  135.  
  136. $this->os_type = $this->os_type();
  137. $this->browser_type = $this->browser_type();
  138. }
  139.  
  140. /**
  141. * begining for formular
  142. * (this function can only handle the session_id, if dbsession_start has
  143. * been called immediately after creating the class object)
  144. *
  145. * @param string $action action {default: PHP_SELF}
  146. * @param string $name name for formular {default: void}
  147. * @param string $method post or get {default: post}
  148. * @param bool $mode false: no session_id, true: with session_id if required {default: true}
  149. * @param string $customize for addon parameters like enctype
  150. * @return string formular head
  151. */
  152. function fm_start($action="", $name="form1", $method="post", $mode=true, $customize="")
  153. {
  154. $with_hidden = false;
  155.  
  156. if (($mode) && ($this->m_dbsession_handler))
  157. {
  158. if (!$this->m_dbsession_cookies)
  159. $with_hidden = true;
  160. }
  161.  
  162. if (isvoid($action)) $action = $_SERVER['PHP_SELF'];
  163. if (isvoid($method)) $method = "post";
  164.  
  165. $rc = "<form action=\"".$action."\"";
  166. if (!empty($name))
  167. {
  168. // save name for other objects
  169. $this->formular_name = $name;
  170. if ($this->set_formular_name) $rc .= " name=\"".$name."\"";
  171. if ($this->set_formular_id) $rc .= " id=\"".$name."\"";
  172. }
  173. $rc .= " method=\"".$method."\"";
  174. if (!empty($customize)) $rc .= " $customize";
  175. $rc .= ">\n";
  176.  
  177. if ($with_hidden)
  178. {
  179. $rc .= $this->fm_hidden($this->m_dbsession_id_name, $this->m_dbsession_id);
  180. }
  181.  
  182. return $rc;
  183. }
  184.  
  185. /**
  186. * close tag for HTML form
  187. *
  188. * @return string
  189. */
  190. function fm_end()
  191. {
  192. $rc = "</form>\n";
  193. return $rc;
  194. }
  195.  
  196. /**
  197. * Add formular error message to stack ($this->form_errors)
  198. *
  199. * @param string $message error message
  200. * @param string $field name of formular object (use , if you want more than one fields)
  201. */
  202. function add_form_error($message, $field=null)
  203. {
  204. if (!empty($message))
  205. {
  206. if ((!isset($field)) || (empty($field)))
  207. {
  208. $field = "global_errors";
  209. }
  210.  
  211. $this->form_errors[$field][] = $message;
  212. }
  213. }
  214.  
  215. /**
  216. * Remove formular error message from error stack ($this->form_errors)
  217. *
  218. * @param string name of formular object (use , if you want more than one fields)
  219. * if no field name is defined, all error messages will be deleted
  220. */
  221. function remove_form_error($field=null)
  222. {
  223. if (isset($field))
  224. {
  225. $fields = array();
  226.  
  227. if (substr_count($field, ","))
  228. {
  229. $fields = explode(",", $field);
  230. }
  231. else
  232. {
  233. $fields[] = $field;
  234. }
  235.  
  236. while(list(, $key)=each($fields))
  237. {
  238. if (array_key_exists($key, $this->form_errors))
  239. {
  240. unset($this->form_errors[$key]);
  241. }
  242. }
  243.  
  244. if (count($this->form_errors)==0)
  245. {
  246. unset($this->form_errors);
  247. }
  248. }
  249. else
  250. {
  251. unset($this->form_errors);
  252. }
  253. }
  254.  
  255. /**
  256. * Exists a formular error
  257. *
  258. * @param string only check this field (use , if you want more than one fields)
  259. * if empty all fields
  260. * @return bool true, if error exists
  261. */
  262. function is_form_error($field=null)
  263. {
  264. $rc = false;
  265.  
  266. if ((is_array($this->form_errors)) && (count($this->form_errors)>0))
  267. {
  268. if (isset($field))
  269. {
  270. $fields = array();
  271.  
  272. if (substr_count($field, ","))
  273. {
  274. $fields = explode(",", $field);
  275. }
  276. else
  277. {
  278. $fields[] = $field;
  279. }
  280.  
  281. while(list(, $key)=each($fields))
  282. {
  283. if (array_key_exists($key, $this->form_errors))
  284. {
  285. $rc = true;
  286. break;
  287. }
  288. }
  289. }
  290. else
  291. {
  292. $rc = true;
  293. }
  294. }
  295.  
  296. return $rc;
  297. }
  298.  
  299. /**
  300. * Get formular error messages
  301. *
  302. * @return bool true, if error exists
  303. */
  304. function get_form_errors()
  305. {
  306. $rc = array();
  307.  
  308. reset($this->form_errors);
  309. while(list(, $enote)=each($this->form_errors))
  310. {
  311. if (is_array($enote))
  312. {
  313. while(list(, $d_enote)=each($enote))
  314. {
  315. $rc[] = $d_enote;
  316. }
  317. }
  318. else
  319. {
  320. $rc[] = $enote;
  321. }
  322. }
  323.  
  324. return $rc;
  325. }
  326.  
  327. /**
  328. * show all formular errors
  329. *
  330. * @return string html list of errors
  331. */
  332. function show_form_errors()
  333. {
  334. $output = "";
  335.  
  336. if ($this->is_form_error())
  337. {
  338. $err_count = 0;
  339. reset($this->form_errors);
  340.  
  341. $message_block = "";
  342.  
  343. while(list(, $messages)=each($this->form_errors))
  344. {
  345. while(list(, $message)=each($messages))
  346. {
  347. if (!empty($message))
  348. {
  349. $err_count++;
  350. $message_block .= "<li class=\"".$this->class_error_body."\">$message</li>\n";
  351. }
  352. }
  353. }
  354.  
  355. $output .= "\n<div class=\"".$this->class_error_header."\">";
  356. $output .= "<img src=\"".$this->image_url."/form_error.gif\" style=\"border: 0;\" alt=\"\"".$this->end_tag()."&nbsp;";
  357. $output .= "<span style=\"font-weight: bold;\">".STR_FORM_ERROR_HEADER."&nbsp;(".$err_count."):</span>";
  358. $output .= "<br".$this->end_tag()."<ul>\n";
  359.  
  360. if ($err_count>0)
  361. {
  362. $output .= $message_block;
  363. }
  364. else
  365. {
  366. $output .="<li class=\"".$this->class_error_body."\">error message is missing. Please call for support.</li>\n";
  367. }
  368.  
  369. $output .= "</ul></div>\n";
  370. }
  371. else
  372. {
  373. $this->show_error("show_form_errors", "error message is missing");
  374. }
  375.  
  376. return $output;
  377. }
  378.  
  379. /**
  380. * Get error CSS class
  381. *
  382. * If err_mode = false and "global_errors" are defined, no shadow class is used! (inactive)
  383. *
  384. * @param string $name
  385. * @param bool $with_opera_color
  386. * @return string
  387. */
  388. function get_error_class($name, $with_opera_color=false)
  389. {
  390. $rc = "";
  391.  
  392. if ($this->is_form_error())
  393. {
  394. // temp array
  395. $form_errors = array();
  396.  
  397. reset($this->form_errors);
  398. while(list($keys, $messages)=each($this->form_errors))
  399. {
  400. if (substr_count($keys, ","))
  401. {
  402.  
  403. $sub_keys = explode(",", $keys);
  404. while(list(, $key)=each($sub_keys))
  405. {
  406. $form_errors[$key] = $messages;
  407. }
  408. }
  409. else
  410. {
  411. $form_errors[$keys] = $messages;
  412. }
  413. }
  414.  
  415. if ($this->err_mode)
  416. {
  417. if ((array_key_exists($name, $form_errors)) &&
  418. (is_array($form_errors[$name])))
  419. {
  420. if ($with_opera_color)
  421. {
  422. $rc .= " style=\"color: ".$this->error_color.";\"";
  423. }
  424. else
  425. {
  426. $rc .= " class=\"".$this->class_shadow."\"";
  427. }
  428. }
  429. }
  430. else if (!array_key_exists("global_errors", $form_errors))
  431. {
  432. if ((!array_key_exists($name, $form_errors)) ||
  433. (array_key_exists($name, $form_errors)) && (!is_array($form_errors[$name])))
  434. {
  435. if ($with_opera_color)
  436. {
  437. $rc .= " style=\"color: ".$this->error_color.";\"";
  438. }
  439. else
  440. {
  441. $rc .= " class=\"".$this->class_shadow."\"";
  442. }
  443. }
  444. }
  445. }
  446.  
  447. if ((empty($rc)) && (!empty($this->class_non_error))) $rc = " class=\"".$this->class_non_error."\"";
  448.  
  449. return $rc;
  450. }
  451.  
  452. /**
  453. * calculates select start for formular
  454. *
  455. * @param string $name name of select tag
  456. * @param array $fmdata array with options
  457. * value:
  458. * desc:
  459. * default: if true, this entry will be selected {default: false}
  460. * convert: if true, convert to html {default: true}
  461. * customize: other values like styles or ids
  462. * @param string $active if actuve is value a valid, this entry is selected {default: first in data array}
  463. * @param string $options other tag parameters
  464. * @param string $onchange onchange event
  465. * @return string
  466. */
  467. function fm_select($name, $fmdata, $active=null, $options="", $onchange="")
  468. {
  469. if (!is_array($fmdata))
  470. {
  471. $this->show_error("fm_select", "missing fmdata array", $fmdata);
  472. }
  473.  
  474. // check if valid value will be found
  475. if (!empty($active))
  476. {
  477. $active_found=false;
  478. reset($fmdata);
  479. while(list(, $specs)=each($fmdata))
  480. {
  481. if ($active==$specs['value'])
  482. {
  483. $active_found=true;
  484. break;
  485. }
  486. }
  487. // if not, set active to default value
  488. if (!$active_found)
  489. {
  490. reset($fmdata);
  491. while(list(, $specs)=each($fmdata))
  492. {
  493. if ($specs['default']==true)
  494. {
  495. $active = $specs['value'];
  496. break;
  497. }
  498. }
  499. }
  500. }
  501. ///////////////////////////////////////////////////////
  502.  
  503. $rc = "<select name=\"$name\"";
  504. $rc .= $this->get_error_class($name);
  505.  
  506. if (!empty($options)) $rc .= " $options";
  507. if (!empty($onchange)) $rc .= " onchange=\"$onchange;\"";
  508. $rc .= ">\n";
  509.  
  510. reset($fmdata);
  511. $select_set = false;
  512. while(list(, $specs)=each($fmdata))
  513. {
  514. $rc .= "\t<option value=\"".$specs['value']."\"";
  515. if (($active==$specs['value']) && (!$select_set))
  516. {
  517. $select_set = true;
  518. $rc .= " selected=\"selected\"";
  519. }
  520. else if ((isset($specs['default'])) &&
  521. ($specs['default']==true) &&
  522. (!$select_set) &&
  523. (isvoid($active, true)))
  524. {
  525. $select_set = true;
  526. $rc .= " selected=\"selected\"";
  527. }
  528. if (isset($specs['customize'])) $rc .= " ".$specs['customize'];
  529. $rc .= ">";
  530.  
  531. if (isset($specs['convert']))
  532. {
  533. if ($specs['convert']) $rc .= $this->convHtml($specs['desc']);
  534. else $rc .= $specs['desc'];
  535. }
  536. else $rc .= $this->convHtml($specs['desc']);
  537. $rc .= "</option>\n";
  538. }
  539. $rc .= "</select>\n";
  540.  
  541. return $rc;
  542. }
  543.  
  544. /**
  545. * calculates submit button string
  546. *
  547. * @param string $name name of the button
  548. * @param string $value value of the button
  549. * @param string $customize other formular parameters, e.g. CLASS
  550. * @return string submit button string for formular
  551. */
  552. function fm_submit($name,$value,$customize="")
  553. {
  554. if (strlen($value)<10)
  555. $value = "&nbsp;&nbsp;".$value."&nbsp;&nbsp;";
  556.  
  557. $rc = "<input type=\"submit\" class=\"".$this->class_button."\" name=\"$name\" value=\"$value\"";
  558. if (!empty($customize))
  559. $rc .= " $customize";
  560. $rc .= $this->end_tag();
  561. return $rc;
  562. }
  563.  
  564. /**
  565. * Calculates button string
  566. *
  567. * @param string $name name of the button
  568. * @param string $value value of the button
  569. * @param string $onclick onclick event (e.g. javascript:...)
  570. * @param string $customize other tag parameter options like CLASS
  571. * @return string
  572. */
  573. function fm_button($name, $value, $onclick, $customize="")
  574. {
  575. if (strlen($value)<10)
  576. $value = "&nbsp;&nbsp;".$value."&nbsp;&nbsp;";
  577.  
  578. $rc = "<input type=\"button\" class=\"".$this->class_button."\" name=\"$name\" value=\"$value\" onclick=\"$onclick;\"";
  579. if (!empty($customize))
  580. {
  581. $rc .= " $customize";
  582. }
  583.  
  584. $rc .= $this->end_tag();
  585.  
  586. return $rc;
  587. }
  588.  
  589. /**
  590. * calculates image button
  591. *
  592. * @param string $name name of the button
  593. * @param string $image_name image name
  594. * @param string $alt_name alt text for image
  595. * @param string $onclick onclick event (e.g. javascript:...)
  596. * @param string $customize other tag parameter options like CLASS
  597. * @return string button string for formular
  598. */
  599. function fm_image($name, $image_name, $alt_name, $onclick="", $customize="")
  600. {
  601. $rc = "<input type=\"image\" class=\"".$this->class_button."\"";
  602. if (!isvoid($name)) $rc .= " name=\"$name\"";
  603. $rc .= " src=\"$image_name\" alt=\"$alt_name\" style=\"border: none; background-color: transparent;\"";
  604.  
  605. if (!empty($onclick)) $rc .= " onclick=\"$onclick;\"";
  606. if (!empty($customize)) $rc .= " $customize";
  607. $rc .= $this->end_tag();
  608.  
  609. return $rc;
  610. }
  611.  
  612. /**
  613. * calculates file input field
  614. *
  615. * @param string $name
  616. * @param int $size
  617. * @param string $onchange
  618. * @param string $customize
  619. * @return string
  620. */
  621. function fm_file($name, $size, $onchange="",$customize="")
  622. {
  623. $rc = "<input type=\"file\" name=\"$name\" size=\"$size\"";
  624.  
  625. $rc .= $this->get_error_class($name);
  626.  
  627. if (!empty($onchange)) $rc .= " onchange=\"$onchange;\"";
  628. if (!empty($customize)) $rc .= " $customize";
  629. $rc .= $this->end_tag();
  630.  
  631. return $rc;
  632. }
  633.  
  634. /**
  635. * calculates text field for formular
  636. *
  637. * @param string $name name of text tag
  638. * @param string $value content of text tag
  639. * @param string $cols number of colomns
  640. * @param string $rows number of rows
  641. * @param string $options other formular parameters like CLASS
  642. * @param int $text_mode 0: no edit options
  643. * 1: no edit options, with mce
  644. * 2: edit options, text active
  645. * 3: edit options, mce small active
  646. * 4: edit options, mce large active
  647. * @param bool $with_hidden_field
  648. * @return string text field string for formular
  649. */
  650. function fm_text($name, $value="", $cols="", $rows="", $options="", $text_mode=0, $with_hidden_field=true)
  651. {
  652. if ($cols=="smallest") $cols_value = 20;
  653. else if ($cols=="small") $cols_value = 30;
  654. else if ($cols=="medium") $cols_value = 38;
  655. else if ((empty($cols)) || ($cols=="default")) $cols_value = 45;
  656. else if ($cols=="big") $cols_value = 50;
  657. else if ($cols=="biggest") $cols_value = 65;
  658. else if ($cols=="s10") $cols_value = 76;
  659. else $cols_value = $cols;
  660.  
  661. if ($rows=="smallest") $rows_value = 3;
  662. else if ($rows=="small") $rows_value = 4;
  663. else if ($rows=="medium") $rows_value = 5;
  664. else if ((empty($rows)) || ($rows=="default")) $rows_value = 6;
  665. else if ($rows=="big") $rows_value = 8;
  666. else if ($rows=="biggest") $rows_value = 12;
  667. else if ($rows=="s10") $rows_value = 15;
  668. else $rows_value = $rows;
  669.  
  670. if ($this->browser_type=="i")
  671. $cols_value += 3;
  672. else if ($this->os_type=="w")
  673. $cols_value -= 1;
  674. else if ($this->browser_type=="o")
  675. $cols_value += 2;
  676.  
  677. $output = "";
  678.  
  679. if ($text_mode>1)
  680. {
  681. $output .= "<table cellpadding=\"0\" style=\"width: 100%\">
  682. <tr><td align=\"right\" style=\"background-color: #f0f0ee;\">";
  683.  
  684. if ($with_hidden_field)
  685. {
  686. $output .= $this->fm_hidden("run_text_mode", 0, true);
  687. }
  688.  
  689. $formdef = "document.mask";
  690. $start_url = "javascript:".$formdef.".text_mode.value=";
  691. $mode_url = $formdef.".run_text_mode.value=1;".$formdef.".submit()";
  692.  
  693. if ($text_mode==2) $output .= "<img src=\"".IMAGE_URL."/button_text_active.gif\" alt=\"".STR_TEXT_VIEW."\" title=\"".STR_TEXT_VIEW."\" style=\"border: 0;\"".$this->end_tag();
  694. else $output .= $this->url($start_url."2;".$mode_url, "<img src=\"".IMAGE_URL."/button_text.gif\" alt=\"".STR_TEXT_VIEW."\" title=\"".STR_TEXT_VIEW."\" style=\"border: 0;\"".$this->end_tag(), 1, STR_TEXT_VIEW);
  695. $output .= "&nbsp;";
  696. if ($text_mode==3) $output .= "<img src=\"".IMAGE_URL."/button_mce_active.gif\" alt=\"".STR_MCE_VIEW."\" title=\"".STR_MCE_VIEW."\" style=\"border: 0;\"".$this->end_tag();
  697. else $output .= $this->url($start_url."3;".$mode_url, "<img src=\"".IMAGE_URL."/button_mce.gif\" alt=\"".STR_MCE_VIEW."\" title=\"".STR_MCE_VIEW."\" style=\"border: 0;\"".$this->end_tag(), 1, STR_MCE_VIEW);
  698. $output .= "&nbsp;";
  699. if ($text_mode==4) $output .= "<img src=\"".IMAGE_URL."/button_mce_large_active.gif\" alt=\"".STR_MCE_VIEW_LARGE."\" title=\"".STR_MCE_VIEW_LARGE."\" style=\"border: 0;\"".$this->end_tag();
  700. else $output .= $this->url($start_url."4;".$mode_url, "<img src=\"".IMAGE_URL."/button_mce_large.gif\" alt=\"".STR_MCE_VIEW_LARGE."\" title=\"".STR_MCE_VIEW_LARGE."\" style=\"border: 0;\"".$this->end_tag(), 1, STR_MCE_VIEW_LARGE);
  701.  
  702. $output .= "</td></tr><tr><td>";
  703. }
  704.  
  705. $output .= "<textarea name=\"$name\"";
  706. $output .= " cols=\"$cols_value\"";
  707.  
  708. if ($text_mode==4) $output .=" rows=\"32\"";
  709. else $output .=" rows=\"$rows_value\"";
  710.  
  711. $output .= $this->get_error_class($name);
  712.  
  713. if (!empty($options)) $output .= " $options";
  714. if (($text_mode!=0) && ($text_mode!=2)) $output .= " mce_editable=\"true\"";
  715. $output .= ">";
  716. if (!isvoid($value))
  717. {
  718. if ($text_mode>1) $output .= nl2br($value);
  719. else $output .= $this->convHtml($value);
  720. }
  721. $output .= "</textarea>";
  722.  
  723. if ($text_mode>1)
  724. {
  725. $output .= "</td></tr></table>";
  726. }
  727.  
  728. return $output;
  729. }
  730.  
  731. /**
  732. * calculates Date select string
  733. *
  734. * @param array $customize array with the following keys:
  735. * name_year = select box name for year
  736. * name_month = select box name for month
  737. * name_day = select box name for day
  738. * name_hour = select box name for hour
  739. * name_minute = select box name for minute
  740. * value_year = selected year {default: current year}
  741. * value_month = selected month {default: current month}
  742. * value_day = selectd day {default: current day}
  743. * value_hour = selected hour {default: current hour}
  744. * value_minute = selected_minute {default: current minute}
  745. * with_time = it true, with time and title {default: false}
  746. * with_alltime = it true, with alltime event {default: false}
  747. * name_alltime = name of alltime checkbox
  748. * value_alltime = if "Y", it is selected {default: "N"}
  749. * minute_int = minute interval 1, 5, 10 or 15 {default: 5 }
  750. * with_run = true, if with run button {default: false}
  751. * prefix = if defined, it will be print
  752. * in front of the first select box
  753. * start_year = set this, if the selection shall not start from year 1970
  754. * end_year = set this, if the selection shall not end after year 2037
  755. * @param string $options other tag parameters like readonly or class
  756. * @return string date select string for formular
  757. */
  758. function fm_date($customize, $options="")
  759. {
  760. if (empty($customize['start_year']))
  761. $customize['start_year'] = 1901;
  762. if ((empty($customize['end_year'])) || (intval($customize['end_year'])>2037))
  763. $customize['end_year'] = 2037;
  764.  
  765. if (empty($customize['name_year'])) $this->show_error("fm_date", "name_year is missing");
  766. if (empty($customize['name_month'])) $this->show_error("fm_date", "name_month is missing");
  767. if (empty($customize['name_day'])) $this->show_error("fm_date", "name_day is missing");
  768. if ($customize['with_time']!=true) $customize['with_time'] = false;
  769. if ($customize['with_run']!=true) $customize['with_run'] = false;
  770.  
  771. if ((isvoid($customize['value_year'])) || ($customize['value_year']<$customize['start_year']) || ($customize['value_year']>$customize['end_year']))
  772. $customize['value_year'] = date('Y');
  773.  
  774. if ((empty($customize['value_month'])) || ($customize['value_month']>12))
  775. $customize['value_month'] = date('m');
  776.  
  777. if ((empty($customize['value_day'])) || ($customize['value_day']>31))
  778. $customize['value_day'] = date('d');
  779.  
  780. if ($customize['with_time'])
  781. {
  782. if (empty($customize['name_hour']))
  783. {
  784. $this->show_error("fm_date", "name_hour is missing");
  785. }
  786. else if (empty($customize['name_minute']))
  787. {
  788. $this->show_error("fm_date", "name_minute is missing");
  789. }
  790.  
  791. if ((isvoid($customize['value_hour'])) || ($customize['value_hour']>23))
  792. $customize['value_hour'] = date('H');
  793. if ((isvoid($customize['value_minute'])) || ($customize['value_minute']>59))
  794. $customize['value_minute'] = date('i');
  795.  
  796. if (($customize['with_alltime']) && (empty($customize['name_alltime'])))
  797. {
  798. $this->show_error("fm_date", "name_alltime is missing");
  799. }
  800. }
  801.  
  802. $rc = "<table cellpadding=\"0\" cellspacing=\"0\" style=\"border: 0;\"><tr>";
  803. if (!isvoid($customize['prefix'])) $rc .= "<td>".$customize['prefix'].":&nbsp;</td>";
  804. $rc .= "<td>\n";
  805.  
  806. if ($customize['with_time']) $rc .= STR_DATE.":<br".$this->end_tag();
  807.  
  808. // day
  809. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  810. $fmdata = array();
  811. for ($i=1;$i<32;$i++)
  812. {
  813. if (strlen($i)<2) $show_i = "0".$i;
  814. else $show_i = $i;
  815. $fmdata[] = array('value'=>$i, 'desc'=>$show_i."&nbsp;", 'convert'=>false);
  816. }
  817. $rc_day = $this->fm_select($customize['name_day'], $fmdata, $customize['value_day'], $options);
  818.  
  819. // month
  820. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  821. unset($fmdata);
  822. $fmdata = array();
  823. for ($i=1;$i<13;$i++)
  824. {
  825. $fmdata[] = array('value'=>$i, 'desc'=>Date_Calc::getMonthFullname($i));
  826. }
  827. $rc_month = $this->fm_select($customize['name_month'], $fmdata, $customize['value_month'], $options);
  828.  
  829. // year
  830. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  831. unset($fmdata);
  832. $fmdata = array();
  833. for ($i=$customize['start_year'];$i<=$customize['end_year'];$i++)
  834. {
  835. $fmdata[] = array('value'=>$i, 'desc'=>$i."&nbsp;", 'convert'=>false);
  836. }
  837. $rc_year = $this->fm_select($customize['name_year'], $fmdata, $customize['value_year'], $options);
  838.  
  839. if ($this->date_format=="I") $rc .= $rc_month.$rc_day.$rc_year;
  840. else if ($this->date_format=="S") $rc .= $rc_year.$rc_month.$rc_day;
  841. else $rc .= $rc_day.$rc_month.$rc_year;
  842.  
  843. if ($customize['with_time'])
  844. {
  845. $rc .= "</td><td>";
  846. $rc .= "&nbsp;&nbsp;".STR_TIME.":<br".$this->end_tag()."&nbsp;&nbsp;";
  847.  
  848. // minute
  849. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  850. $fmdata_m = array();
  851.  
  852. if ((!isvoid($customize['minute_int'])) && (!isvoid(array_search($customize['minute_int'], array(1, 5, 10, 15)))))
  853. $minute_int = $customize['minute_int'];
  854. else
  855. $minute_int = 5; // default
  856.  
  857. for ($i=0; $i<60; $i=$i+$minute_int)
  858. {
  859. if (($customize['value_minute']!=$i) && ($minute_int>1) &&
  860. (($i<$customize['value_minute']) && (($customize['value_minute']+$minute_int*2)>59)) ||
  861. (($i>$customize['value_minute']) &&
  862. ($i<($customize['value_minute']+$minute_int)) &&
  863. ($customize['value_minute']+$minute_int)<=59))
  864. $default = true;
  865. else
  866. $default = false;
  867.  
  868. if (strlen($i)<2) $show_i = "0".$i;
  869. else $show_i = $i;
  870.  
  871. $fmdata_m[] = array('value'=>$i, 'desc'=>$show_i."&nbsp;", 'convert'=>false, 'default'=>$default);
  872. }
  873.  
  874. // hour
  875. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  876. $fmdata_h = array();
  877. for ($i=0;$i<24;$i++)
  878. {
  879. if (($this->time_format=="Y") || ($i>0))
  880. {
  881. if ($this->time_format=="Y")
  882. {
  883. if (strlen($i)<2) $curr_time = "0".$i;
  884. else $curr_time = $i;
  885. }
  886. else
  887. {
  888. if ($i>12) $curr_time = ($i-12)." pm";
  889. else $curr_time = $i." am";
  890. }
  891. $fmdata_h[] = array('value'=>$i, 'desc'=>$curr_time."&nbsp;", 'convert'=>false);
  892. }
  893. }
  894. if ($this->time_format!="Y")
  895. $fmdata_h[] = array('value'=>0, 'desc'=>"12 pm&nbsp;", 'convert'=>false);
  896.  
  897. if ((($customize['value_minute']+$minute_int)>59) && ($customize['value_hour']<=23))
  898. {
  899. $customize['value_hour']++;
  900. }
  901.  
  902. // show time
  903. $rc .= $this->fm_select($customize['name_hour'], $fmdata_h, $customize['value_hour'], "style=\"text-align: right;\" ".$options);
  904.  
  905. $rc .= $this->fm_select($customize['name_minute'], $fmdata_m, $customize['value_minute'], $options);
  906.  
  907. if ($customize['with_alltime'])
  908. {
  909. $rc .= "&nbsp;&nbsp;&nbsp;&nbsp;";
  910. $rc .= $this->fm_checkbox($customize['name_alltime'], "Y", STR_APPOINTMENT_ALLDAY, $customize['value_alltime'], $options);
  911. }
  912. }
  913.  
  914. $rc .= "</td>\n";
  915. if ($customize['with_run'])
  916. $rc .= "<td>&nbsp;".$this->fm_image("", $this->image_url."/goto.gif", STR_CALENDAR_JUMPTO, "", $customize="", $options)."</td>\n";
  917. $rc .= "</tr></table>\n";
  918.  
  919. return $rc;
  920. }
  921.  
  922. /**
  923. * Hidden field
  924. *
  925. * @param string $field_name
  926. * @param string $field_value
  927. * @param bool $mode false: if empty, don't print it
  928. * @return string
  929. */
  930. function fm_hidden($field_name, $field_value="", $mode=false)
  931. {
  932. $output = "";
  933.  
  934. if ((!isvoid($field_value)) || ((isvoid($field_value)) && ($mode)))
  935. {
  936. $output .= "\t<input type=\"hidden\" name=\"$field_name\" value=\"";
  937. if (is_int($field_value)) $output .= $field_value;
  938. else $output .= $this->convHtml($field_value);
  939. $output .= "\"".$this->end_tag()."\n";
  940. }
  941.  
  942. return $output;
  943. }
  944.  
  945. /**
  946. * checkbox for formular
  947. *
  948. * @param string $name
  949. * @param string $value
  950. * @param string $desc description behind checkbox
  951. * @param string $active_value active checkbox
  952. * @param string $options other optional tag parameters
  953. * @return string
  954. */
  955. function fm_checkbox($name, $value, $desc, $active_value="", $options="")
  956. {
  957. $rc = "<input type=\"checkbox\" name=\"$name\"";
  958.  
  959. $rc .= " value=\"";
  960. if (is_int($value)) $rc .= $value;
  961. else $rc .= $this->convHtml($value);
  962. $rc .= "\"";
  963.  
  964. if ($active_value==$value) $rc .= " checked=\"checked\"";
  965.  
  966. if ($this->browser_type=="i") // fix ie style fault
  967. $rc .= " style=\"background-color: transparent; border-style: none;\"";
  968.  
  969. if (!empty($options)) $rc .= " $options";
  970.  
  971. if (!isvoid($desc))
  972. {
  973. $id_name = str_replace("[", "-", $name);
  974. $id_name = str_replace("]", "-", $id_name);
  975.  
  976. $rc .= " id=\"".$id_name."\"".$this->end_tag();
  977. $rc .= "<label for=\"".$id_name."\">".$desc."</label>";
  978. }
  979. else
  980. {
  981. $rc .= $this->end_tag();
  982. }
  983.  
  984. return $rc;
  985. }
  986.  
  987. /**
  988. * checkbox for formular
  989. *
  990. * @param string $name
  991. * @param string $value
  992. * @param string $desc description behind radio button
  993. * @param string $active_value active radio
  994. * @param string $alt_values alternate active values for other radio buttons. If no other radio button is correct,
  995. * that one with optional alt_values will be checked
  996. * @param string $options other optional tag parameters
  997. * @return string string with checkbox for formular
  998. */
  999. function fm_radio($name, $value, $desc, $active_value="", $alt_values="", $options="")
  1000. {
  1001. $rc = "\t<input type=\"radio\" name=\"$name\"";
  1002. if ($this->browser_type=="i") // fix ie style fault
  1003. $rc .= "style=\"background-color: transparent; border-style: none;\"";
  1004. else if ($this->browser_type=="o") // only works with opera
  1005. {
  1006. $rc .= $this->get_error_class($name, true);
  1007. }
  1008.  
  1009. $rc .= " value=\"";
  1010. if (is_int($value)) $rc .= $value;
  1011. else $rc .= $this->convHtml($value);
  1012. $rc .= "\"";
  1013.  
  1014. if ($active_value==$value) $rc .= " checked=\"checked\"";
  1015. else if (!isvoid($alt_values))
  1016. {
  1017. $found=false;
  1018. // if alt_value exists and active_value is empty, mark it as checked
  1019. if (!isvoid($active_value))
  1020. {
  1021. $ed = explode(",", $alt_values);
  1022. while(list(, $val)=each($ed))
  1023. {
  1024. if ($val==$active_value)
  1025. {
  1026. $found=true;
  1027. break;
  1028. }
  1029. }
  1030. }
  1031. if (!$found) $rc .= " checked=\"checked\"";
  1032. }
  1033. if (!empty($options)) $rc .= " $options";
  1034.  
  1035. if (!isvoid($desc))
  1036. {
  1037. $id_name = $name."-".$value;
  1038. $id_name = str_replace("[", "-", $id_name);
  1039. $id_name = str_replace("]", "-", $id_name);
  1040.  
  1041. $rc .= " id=\"".$id_name."\"".$this->end_tag();
  1042. $rc .= "<label for=\"".$id_name."\">".$desc."</label>";
  1043. }
  1044. else
  1045. {
  1046. $rc .= $this->end_tag();
  1047. }
  1048. $rc .= "\n";
  1049.  
  1050. return $rc;
  1051. }
  1052.  
  1053. /**
  1054. * calculats input tag for formular
  1055. *
  1056. * @param string $name
  1057. * @param string $value
  1058. * @param mixed $size smallest,small,medium (2xmedium=normal), default or big
  1059. * @param int $maxlength maximum input length
  1060. * @param string $options other optional tag parameters
  1061. * @param array $customize
  1062. * @return string string with input tag for formular
  1063. */
  1064. function fm_input($name, $value="", $size="", $maxlength="", $options="", $customize=null)
  1065. {
  1066. $is_password_field = false;
  1067. $password_generate_button = false;
  1068. $password_show_button = false;
  1069. $url_button = false;
  1070. $email_button = false;
  1071. $date_button = false;
  1072. $button_space = false;
  1073.  
  1074. if (isset($customize))
  1075. {
  1076. if (array_key_exists("is_password_field", $customize)) $is_password_field = $customize['is_password_field'];
  1077. if (array_key_exists("password_generate_button", $customize)) $password_generate_button = $customize['password_generate_button'];
  1078. if (array_key_exists("password_show_button", $customize)) $password_show_button = $customize['password_show_button'];
  1079. if (array_key_exists("url_button", $customize)) $url_button = $customize['url_button'];
  1080. if (array_key_exists("email_button", $customize)) $email_button = $customize['email_button'];
  1081. if (array_key_exists("date_button", $customize)) $date_button = $customize['date_button'];
  1082. if (array_key_exists("button_space", $customize)) $button_space = $customize['button_space'];
  1083. }
  1084. /////////////////////////////
  1085.  
  1086. $ptype=0;
  1087.  
  1088. if ($size=="s1") $size_value = 8;
  1089. else if ($size=="s2") $size_value = 11;
  1090. else if ($size=="s3") $size_value = 15; // 15
  1091. else if ($size=="s4") $size_value = 20; // 20
  1092. else if ($size=="s5") $size_value = 25; // 27
  1093. else if ((empty($size)) || ($size=="s6")) $size_value = 30; // 32
  1094. else if ($size=="s7") $size_value = 36; // 36
  1095. else if ($size=="s8") $size_value = 41;
  1096. else if ($size=="s9") $size_value = 48;
  1097. else if ($size=="s10") $size_value = 58;
  1098. else $size_value = $size;
  1099.  
  1100. if ($this->browser_type=="i")
  1101. $size_value -= 2;
  1102. else if (($this->os_type=="w") && ($size_value<25) && ($size_value>11))
  1103. $size_value -= 3;
  1104. else if (($this->browser_type=="o") && ($size_value<25) && ($size_value>11))
  1105. $size_value += 1;
  1106.  
  1107. // new_passwd = same as new_pwd
  1108. if ((substr($name,0,7)=="new_pwd") || (substr($name,0,10)=="new_passwd"))
  1109. $ptype=1; // because of an Opera bug, I turned password fields to 0 (default:1)
  1110. else if ($name=="upwd")
  1111. $ptype=2;
  1112.  
  1113. $rc = "<input type=\"";
  1114. if ($ptype==1) $rc .= "password";
  1115. else $rc .= "text";
  1116.  
  1117. $rc .= "\" name=\"$name\"";
  1118.  
  1119. if (!isvoid($value)) $rc .= " value=\"".$this->convHtml($value)."\"";
  1120.  
  1121. $rc .= " size=\"$size_value\"";
  1122. if (!empty($maxlength)) $rc .= " maxlength=\"$maxlength\"";
  1123.  
  1124. $rc .= $this->get_error_class($name);
  1125.  
  1126. if (!empty($options)) $rc .= " $options";
  1127.  
  1128. $rc .= $this->end_tag();
  1129.  
  1130. if ((($name=="new_email") || (substr($name, 0, 5)=="email")) && (!isvoid($value)) && (!$this->is_form_error($name)))
  1131. {
  1132. $rc .= "&nbsp;<a style=\"background: none;\" href=\"mailto:$value\"><img src=\"".$this->image_url."/mail.gif\" alt=\"".STR_SHOW_EMAIL."\" title=\"".STR_SHOW_EMAIL."\" style=\"border: 0;\"".$this->end_tag()."</a>";
  1133. }
  1134. else if ((((substr($name,0,7))=="new_url") || ((substr($name,0,3))=="url") || ($url_button)) && (!isvoid($value)) && (!$this->is_form_error($name)))
  1135. {
  1136. $rc .= "&nbsp;".$this->url($this->convHtml($this->convURL($value)),
  1137. "<img src=\"".$this->image_url."/url.gif\" alt=\"".STR_SHOW_URL."\" title=\"".STR_SHOW_URL."\" style=\"border: 0;\"".$this->end_tag(),
  1138. 1,
  1139. "",
  1140. "target=\"_blank\" style=\"background: none;\"");
  1141. }
  1142. if (($name=="new_pic") && (!isvoid($value)) && (!$this->is_form_error($name)))
  1143. {
  1144. $rc .= "&nbsp;".$this->url($this->convHtml($this->convUrl($value)),
  1145. "<img src=\"".$this->image_url."/url_pic.gif\" alt=\"".STR_SHOW_PIC."\" title=\"".STR_SHOW_PIC."\" style=\"border: 0;\"".$this->end_tag(),
  1146. 1,
  1147. "",
  1148. "style=\"background: none;\"");
  1149. }
  1150. else if (($name=="new_spec") && (!isvoid($value)) && (!$this->is_form_error($name)))
  1151. {
  1152. $rc .= "&nbsp;".$this->url($this->convHtml($this->convUrl($value)),
  1153. "<img src=\"".$this->image_url."/url_spec.gif\" alt=\"".STR_SHOW_SPEC."\" title=\"".STR_SHOW_SPEC."\" style=\"border: 0;\"".$this->end_tag(),
  1154. 1,
  1155. "",
  1156. "style=\"background: none;\"");
  1157. }
  1158. else if (($name=="new_cdate") || ($name=="cdate")) // with date
  1159. {
  1160. if ((substr_count($options,"readonly")==0) && (substr_count($options,"disabled")==0))
  1161. {
  1162. $rc .= "&nbsp;<a href=\"javascript:getcdate();\" onmouseover=\"window.status='".STR_DATE_SETTODAY."';return true\" onmouseout=\"window.status=''\" style=\"background: none;\">";
  1163. $rc .= "<img src=\"".$this->image_url."/last_contact.gif\" alt=\"".STR_DATE_SETTODAY."\" title=\"".STR_DATE_SETTODAY."\" style=\"border: 0;\"".$this->end_tag();
  1164. $rc .= "</a>";
  1165. }
  1166. }
  1167. else if (($name=="new_ddate") || ($name=="ddate")) // with date
  1168. {
  1169. if ((substr_count($options,"readonly")==0) && (substr_count($options,"disabled")==0))
  1170. {
  1171. $rc .= "&nbsp;<a href=\"javascript:getddate();\" onmouseover=\"window.status='".STR_DATE_SETTODAY."';return true\" onmouseout=\"window.status=''\" style=\"background: none;\">";
  1172. $rc .= "<img src=\"".$this->image_url."/last_contact.gif\" alt=\"".STR_DATE_SETTODAY."\" title=\"".STR_DATE_SETTODAY."\" style=\"border: 0;\"".$this->end_tag();
  1173. $rc .= "</a>";
  1174. }
  1175. }
  1176. else if ($ptype==2)
  1177. {
  1178. if ((substr_count($options,"readonly")==0) && (substr_count($options,"disabled")==0))
  1179. {
  1180. $rc .= "&nbsp;<a href=\"javascript:GeneratePassword();\" onmouseover=\"window.status='".STR_PASSWORD_GENERATE."';return true\" onmouseout=\"window.status=''\" style=\"background: none;\">";
  1181. $rc .= "<img src=\"".$this->image_url."/generator.gif\" alt=\"".STR_PASSWORD_GENERATE."\" title=\"".STR_PASSWORD_GENERATE."\" style=\"border: 0;\"".$this->end_tag();
  1182. $rc .= "</a>";
  1183. }
  1184.  
  1185. if ((!isvoid($value)) && (!$this->is_form_error($name)))
  1186. {
  1187. $rc .= "&nbsp;<a href=\"javascript:ShowPassword();\" onmouseover=\"window.status='".STR_PASSWORD_SHOW."';return true\" onmouseout=\"window.status=''\" style=\"background: none;\">";
  1188. $rc .= "<img src=\"".$this->image_url."/glasses.gif\" alt=\"".STR_PASSWORD_SHOW."\" title=\"".STR_PASSWORD_SHOW."\" style=\"border: 0;\"".$this->end_tag();
  1189. $rc .= "</a>";
  1190. }
  1191. else
  1192. $rc .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  1193. }
  1194. else
  1195. {
  1196. // have to be integrated
  1197. // new schema!
  1198.  
  1199. if ($button_space)
  1200. {
  1201. $rc .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  1202. }
  1203. else
  1204. {
  1205. if ($password_generate_button)
  1206. {
  1207. $rc .= "&nbsp;<a href=\"javascript:GeneratePassword();\" onmouseover=\"window.status='".STR_PASSWORD_GENERATE."';return true\" onmouseout=\"window.status=''\" style=\"background: none;\">";
  1208. $rc .= "<img src=\"".$this->image_url."/generator.gif\" alt=\"".STR_PASSWORD_GENERATE."\" title=\"".STR_PASSWORD_GENERATE."\" style=\"border: 0;\"".$this->end_tag();
  1209. $rc .= "</a>";
  1210. }
  1211. if ($password_show_button)
  1212. {
  1213. $rc .= "&nbsp;<a href=\"javascript:ShowPassword();\" onmouseover=\"window.status='".STR_PASSWORD_SHOW."';return true\" onmouseout=\"window.status=''\" style=\"background: none;\">";
  1214. $rc .= "<img src=\"".$this->image_url."/glasses.gif\" alt=\"".STR_PASSWORD_SHOW."\" title=\"".STR_PASSWORD_SHOW."\" style=\"border: 0;\"".$this->end_tag();
  1215. $rc .= "</a>";
  1216. }
  1217. if ($date_button)
  1218. {
  1219. $rc .= "&nbsp;<a href=\"javascript:ShowPassword();\" onmouseover=\"window.status='".STR_PASSWORD_SHOW."';return true\" onmouseout=\"window.status=''\" style=\"background: none;\">";
  1220. $rc .= "<img src=\"".$this->image_url."/glasses.gif\" alt=\"".STR_PASSWORD_SHOW."\" title=\"".STR_PASSWORD_SHOW."\" style=\"border: 0;\"".$this->end_tag();
  1221. $rc .= "</a>";
  1222. }
  1223. }
  1224. }
  1225.  
  1226. return $rc;
  1227. }
  1228.  
  1229. /**
  1230. * draw period form dialog
  1231. *
  1232. * @param array $uvar
  1233. * @param bool $with_userdef true: with user defined period
  1234. * false: without user defined period {default}
  1235. * @param int $first_year
  1236. * @return string period form dialog
  1237. */
  1238. function fm_select_period(&$uvar, $with_userdef=false, $first_year="")
  1239. {
  1240. if (!empty($first_year)) $fm_year = $this->fm_year_options($first_year);
  1241. else $fm_year = $this->fm_year_options();
  1242.  
  1243. if (empty($uvar['period']))
  1244. {
  1245. $uvar['period'] = $this->default_date_period;
  1246. $uvar['year_m'] = date("Y");
  1247. $uvar['month'] = date("m");
  1248. }
  1249.  
  1250. $rc = "<tr><td>".STR_PERIOD.":</td><td>".$this->fm_radio("period", "M", STR_MONTH, $uvar['period'])."&nbsp;</td>";
  1251.  
  1252. $fmdata = $this->fm_month_options();
  1253. $rc .= "<td>".$this->fm_select("month", $fmdata, $uvar['month'])."</td>\n";
  1254.  
  1255. $rc .= "<td align=\"right\">".STR_YEAR.": ";
  1256. $rc .= $this->fm_select("year_m", $fm_year, $uvar['year_m'])."</td></tr>\n";
  1257.  
  1258. $rc .= "<tr><td>&nbsp;</td><td>".$this->fm_radio("period", "Q", STR_QUARTERLY, $uvar['period'])."&nbsp;</td>";
  1259. unset($fmdata);
  1260. $fmdata = $this->fm_quarter_options();
  1261. $rc .= "<td>".$this->fm_select("quarter", $fmdata, $uvar['quarter'])."</td>\n";
  1262.  
  1263. $rc .= "<td align=\"right\">".STR_YEAR.": ";
  1264. $rc .= $this->fm_select("year_q", $fm_year, $uvar['year_q'])."</td></tr>\n";
  1265.  
  1266. $rc .= "<tr><td>&nbsp;</td><td colspan=\"2\">".$this->fm_radio("period", "Y", STR_YEAR, $uvar['period'])."&nbsp;</td>";
  1267. $rc .= "<td align=\"right\">".STR_YEAR.": ";
  1268. $rc .= $this->fm_select("year_y", $fm_year, $uvar['year_y'])."</td></tr>\n";
  1269.  
  1270. if ($with_userdef)
  1271. {
  1272. $rc .= "<tr><td>&nbsp;</td><td>".$this->fm_radio("period", "U", STR_USER_DEFINIED, $uvar['period'])."&nbsp;</td>";
  1273. $rc .= "<td>".STR_PERIOD_FROM.": ".$this->fm_input("user_start",$uvar['user_start'],"s2",10)."</td>";
  1274. $rc .= "<td align=\"right\">".STR_PERIOD_TILL.": ".$this->fm_input("user_end",$uvar['user_end'],"s2",10)."</td>";
  1275. $rc .= "</tr>\n";
  1276. }
  1277.  
  1278. return $rc;
  1279. }
  1280.  
  1281. /**
  1282. * options with quarters
  1283. *
  1284. * @return array
  1285. */
  1286. function fm_quarter_options()
  1287. {
  1288. $fmdata = array();
  1289.  
  1290. $curr_quarter = ceil(date("n")/3);
  1291.  
  1292. for($i=0;$i<4;$i++)
  1293. {
  1294. $curr = $i+1;
  1295.  
  1296. if ($curr_quarter==$curr) $fmdata[] = array('value'=>$curr, 'desc'=>"$curr. ".STR_QUARTER, 'convert'=>false, 'default'=>true);
  1297. else $fmdata[] = array('value'=>$curr, 'desc'=>"$curr. ".STR_QUARTER, 'convert'=>false);
  1298. }
  1299.  
  1300. return $fmdata;
  1301. }
  1302.  
  1303. /**
  1304. * options with months
  1305. *
  1306. * @return array
  1307. */
  1308. function fm_month_options()
  1309. {
  1310. $fmdata = array();
  1311.  
  1312. $curr_month = date("n");
  1313.  
  1314. for($i=0;$i<12;$i++)
  1315. {
  1316. $curr = $i+1;
  1317.  
  1318. if ($curr_month==$curr) $fmdata[] = array('value'=>$curr, 'desc'=>Date_Calc::getMonthFullname($curr), 'convert'=>true, 'default'=>true);
  1319. else $fmdata[] = array('value'=>$curr, 'desc'=>Date_Calc::getMonthFullname($curr), 'convert'=>true);
  1320. }
  1321.  
  1322. return $fmdata;
  1323. }
  1324.  
  1325. /**
  1326. * options with years
  1327. *
  1328. * @param int $first first available year
  1329. * @param int $last
  1330. * @return array
  1331. */
  1332. function fm_year_options($first="", $last="")
  1333. {
  1334. if (isvoid($first))
  1335. {
  1336. $first = $this->first_date_year;
  1337. }
  1338.  
  1339. $fmdata = array();
  1340.  
  1341. $curr_year = date("Y");
  1342.  
  1343. if (!isvoid($last))
  1344. {
  1345. if ($last<$curr_year) $i_max = $curr_year+1;
  1346. else $i_max = $last+1;
  1347. }
  1348. else
  1349. {
  1350. $i_max = $curr_year+1;
  1351. }
  1352.  
  1353. for($i=$first;$i<$i_max;$i++)
  1354. {
  1355. if ($curr_year==$i) $fmdata[] = array('value'=>$i, 'desc'=>$i."&nbsp;&nbsp;", 'convert'=>false, 'default'=>true);
  1356. else $fmdata[] = array('value'=>$i, 'desc'=>$i."&nbsp;&nbsp;", 'convert'=>false);
  1357. }
  1358.  
  1359. return $fmdata;
  1360. }
  1361.  
  1362. /**
  1363. * Get day of month
  1364. *
  1365. * @param int $month
  1366. * @param int $year
  1367. * @return string
  1368. */
  1369. function fm_month_days($month,$year)
  1370. {
  1371. if ($month==12)
  1372. $tmp_month=1;
  1373. else
  1374. $tmp_month = $month+1;
  1375. return date("t",mktime (0,0,0,$tmp_month,0,$year));
  1376. }
  1377. }
  1378. ?>

Documentation generated on Fri, 11 Nov 2005 10:40:00 +0100 by phpDocumentor 1.3.0RC3