loadLanguage('MyEcmCalendarsDashlets'); // load the language strings here if(!empty($def['savedText'])) // load default text is none is defined $this->savedText = $def['savedText']; else $this->savedText = $this->dashletStrings['LBL_DEFAULT_TEXT']; if(!empty($def['height'])) // set a default height if none is set $this->height = $def['height']; $this->act_status = $def['act_status']; $this->act_user = $def['act_user']; $this->act_type = $def['act_type']; parent::Dashlet($id); // call parent constructor $this->isConfigurable = true; // dashlet is configurable $this->hasScript = true; // dashlet has javascript attached to it // if no custom title, use default if(empty($def['title'])) $this->title = 'Mój Kalendarz'; else $this->title = $def['title']; } /** * Displays the dashlet * * @return string html to display dashlet */ function display() { $ss = new Sugar_Smarty(); $ss->assign('savedText', $this->savedText); $ss->assign('saving', $this->dashletStrings['LBL_SAVING']); $ss->assign('saved', $this->dashletStrings['LBL_SAVED']); $ss->assign('id', $this->id); $ss->assign('height', $this->height); $str = $ss->fetch('modules/Home/Dashlets/MyEcmCalendarsDashlets/MyEcmCalendarsDashlets.tpl'); require_once("modules/EcmCalendars/Calendar.php"); require_once("modules/EcmCalendars/language/pl_pl.lang.php"); $cal=new Calendar(); if($_REQUEST['date']) { $exp=explode("-",$_REQUEST['date']); $cal->year=$exp[0]; $cal->month=$exp[1]; } else { $cal->year=date("Y"); $cal->month=date("m"); } $cal->act_status=$this->act_status; $cal->act_user=$this->act_user; $cal->act_type=$this->act_type; if(!$this->act_type)$cal->act_type="All"; $_SESSION['calendar_dashlet_id']=$this->id; $str='
'.$cal->showTableDashlet($cal->month,$cal->year).'
'; return parent::display("") . $str . '
'; // return parent::display for title and such } /** * Displays the javascript for the dashlet * * @return string javascript to use with this dashlet */ function displayScript() { $ss = new Sugar_Smarty(); $ss->assign('saving', $this->dashletStrings['LBL_SAVING']); $ss->assign('saved', $this->dashletStrings['LBL_SAVED']); $ss->assign('id', $this->id); $str = $ss->fetch('modules/Home/Dashlets/MyEcmCalendarsDashlets/MyEcmCalendarsDashletsScript.tpl'); return $str; // return parent::display for title and such } /** * Displays the configuration form for the dashlet * * @return string html to display form */ function displayOptions() { global $app_strings,$GLOBALS; $ss = new Sugar_Smarty(); $arr=array("All","Planned","Held","Not Held"); $as=''; global $app_list_strings; $as.=''; } $ss->assign('act_status_options', $as); $arr=array("All","Calls","Meetings","Tasks"); $at=''; $at.=''; $ss->assign('act_type_options', $at); $ua=''; $w=mysql_query("select user_name,id from users where deleted='0' order by user_name asc"); while($r=mysql_fetch_array($w)) { $ua.=''; } $ss->assign('act_user_options', $ua); $ss->assign('titleLbl', $this->dashletStrings['LBL_CONFIGURE_TITLE']); $ss->assign('statusLbl', $this->dashletStrings['LBL_CONFIGURE_STATUS']); $ss->assign('userLbl', $this->dashletStrings['LBL_CONFIGURE_USER']); $ss->assign('typeLbl', $this->dashletStrings['LBL_CONFIGURE_TYPE']); $ss->assign('saveLbl', $app_strings['LBL_SAVE_BUTTON_LABEL']); $ss->assign('title', $this->title); $ss->assign('height', $this->height); $ss->assign('id', $this->id); return parent::displayOptions() . $ss->fetch('modules/Home/Dashlets/MyEcmCalendarsDashlets/MyEcmCalendarsDashletsOptions.tpl'); } /** * called to filter out $_REQUEST object when the user submits the configure dropdown * * @param array $req $_REQUEST * @return array filtered options to save */ function saveOptions($req) { global $sugar_config, $timedate, $current_user, $theme; $options = array(); $options['title'] = $_REQUEST['title']; $options['act_status'] = $_REQUEST['act_status']; $options['act_user'] = $_REQUEST['act_user']; $options['act_type'] = $_REQUEST['act_type']; if(is_numeric($_REQUEST['height'])) { if($_REQUEST['height'] > 0 && $_REQUEST['height'] <= 300) $options['height'] = $_REQUEST['height']; elseif($_REQUEST['height'] > 300) $options['height'] = '300'; else $options['height'] = '100'; } // $options['savedText'] = br2nl($this->savedText); $options['savedText'] = $this->savedText; return $options; } /** * Used to save text on textarea blur. Accessed via Home/CallMethodDashlet.php * This is an example of how to to call a custom method via ajax */ function saveText() { $json = getJSONobj(); if(isset($_REQUEST['savedText'])) { $optionsArray = $this->loadOptions(); // _pp($_REQUEST['savedText']); $optionsArray['savedText']=$json->decode(html_entity_decode($_REQUEST['savedText'])); $optionsArray['savedText']=nl2br($optionsArray['savedText']['jsonObject']); $this->storeOptions($optionsArray); } else { $optionsArray['savedText'] = ''; } echo 'result = ' . $json->encode(array('id' => $_REQUEST['id'], 'savedText' => $optionsArray['savedText'])); } } ?>