コード例 #1
0
 /**
  * delete deletes the given entry
  * 
  * @param int $cid entry-id for calendar
  * @return string html-string
  */
 private function delete($cid)
 {
     // pagecaption
     $this->tpl->assign('pagecaption', parent::lang('class.CalendarView#page#caption#delete') . ": {$cid}");
     // check rights
     if (Rights::check_rights($cid, 'calendar')) {
         // prepare return
         $output = '';
         // smarty-templates
         $sConfirmation = new JudoIntranetSmarty();
         $form = new HTML_QuickForm2('confirm', 'post', array('name' => 'confirm', 'action' => 'calendar.php?id=delete&cid=' . $this->get('cid')));
         // add button
         $form->addElement('submit', 'yes', array('value' => parent::lang('class.CalendarView#delete#form#yes')));
         // smarty-link
         $link = array('params' => '', 'href' => 'calendar.php?id=listall', 'title' => parent::lang('class.CalendarView#delete#title#cancel'), 'content' => parent::lang('class.CalendarView#delete#form#cancel'));
         $sConfirmation->assign('link', $link);
         $sConfirmation->assign('spanparams', 'id="cancel"');
         $sConfirmation->assign('message', parent::lang('class.CalendarView#delete#message#confirm'));
         $sConfirmation->assign('form', $form);
         // validate
         if ($form->validate()) {
             // get calendar-object
             $calendar = new Calendar($cid);
             // disable entry
             $calendar->update(array('valid' => 0));
             // smarty
             $sConfirmation->assign('message', parent::lang('class.CalendarView#delete#message#done'));
             $sConfirmation->assign('form', '');
             // write entry
             try {
                 $calendar->write_db('update');
             } catch (Exception $e) {
                 $GLOBALS['Error']->handle_error($e);
                 return $GLOBALS['Error']->to_html($e);
             }
         }
         // smarty return
         return $sConfirmation->fetch('smarty.confirmation.tpl');
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
コード例 #2
0
 /**
  * decissions shows the decissions of this or all protocols
  * 
  * @param int $pid entry-id for protocol
  * @return string html of the decissions page
  */
 private function decisions($pid)
 {
     // pagecaption
     $this->tpl->assign('pagecaption', parent::lang('class.ProtocolView#page#caption#decisions'));
     // check rights
     if (Rights::check_rights($pid, 'protocol', true) || $pid == false) {
         // prepare template
         $sD = new JudoIntranetSmarty();
         // check pid all or single
         if ($pid === false) {
             // get protocol ids
             $pids = Protocol::return_protocols();
             // create protocol objects to sort
             $protocols = array();
             foreach ($pids as $pid) {
                 $protocols[] = new Protocol($pid);
             }
             // sort array by protocols date
             usort($protocols, array($this, 'callback_compare_protocols'));
             // walk through ids
             $counter = 0;
             foreach ($protocols as $protocol) {
                 // assign data
                 $data[$counter] = array('date' => $protocol->get_date('d.m.Y'), 'type' => $protocol->get_type(), 'location' => $protocol->get_location(), 'decisions' => $this->parseHtml($protocol->get_protocol(), '<p class="tmceDecision">|</p>'));
                 // check if protocol has decisions
                 if (count($data[$counter]['decisions']) == 0) {
                     unset($data[$counter]);
                 }
                 $data = array_merge($data);
                 // add to template
                 $sD->assign('data', $data);
                 // increment counter
                 $counter++;
             }
         } else {
             // get protocol object
             $protocol = new Protocol($pid);
             // assign data
             $data[] = array('date' => $protocol->get_date('d.m.Y'), 'type' => $protocol->get_type(), 'location' => $protocol->get_location(), 'decisions' => $this->parseHtml($protocol->get_protocol(), '<p class="tmceDecision">|</p>'));
             // add to template
             $sD->assign('data', $data);
         }
         // return
         return $sD->fetch('smarty.protocol.showdecisions.tpl');
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
コード例 #3
0
 /**
  * delete deletes the given entry
  * 
  * @param int $cid entry-id for calendar
  * @return string html-string
  */
 private function delete()
 {
     // check rights
     if (Rights::check_rights($this->get('cid'), 'calendar')) {
         // check cid and pid given
         if ($this->get('cid') !== false && $this->get('pid') !== false) {
             // check cid and pid exists
             if (Calendar::check_id($this->get('cid')) && Preset::check_preset($this->get('pid'), 'calendar')) {
                 // pagecaption
                 $this->tpl->assign('pagecaption', parent::lang('class.AnnouncementView#page#caption#delete'));
                 // prepare return
                 $return = '';
                 // smarty-templates
                 $sConfirmation = new JudoIntranetSmarty();
                 $form = new HTML_QuickForm2('confirm', 'post', array('name' => 'confirm', 'action' => 'announcement.php?id=delete&cid=' . $this->get('cid') . '&pid=' . $this->get('pid')));
                 // add button
                 $form->addElement('submit', 'yes', array('value' => parent::lang('class.AnnouncementView#delete#form#yes')));
                 // smarty-link
                 $link = array('params' => '', 'href' => 'calendar.php?id=listall', 'title' => parent::lang('class.AnnouncementView#delete#title#cancel'), 'content' => parent::lang('class.AnnouncementView#delete#form#cancel'));
                 $sConfirmation->assign('link', $link);
                 $sConfirmation->assign('spanparams', 'id="cancel"');
                 $sConfirmation->assign('message', parent::lang('class.AnnouncementView#delete#message#confirm'));
                 $sConfirmation->assign('form', $form);
                 // validate
                 if ($form->validate()) {
                     // get calendar-object
                     $calendar = new Calendar($this->get('cid'));
                     // get preset
                     $preset = new Preset($this->get('pid'), 'calendar', $this->get('cid'));
                     // get fields
                     $fields = $preset->get_fields();
                     // delete values of the fields
                     if (Calendar::check_ann_value($calendar->get_id(), $calendar->get_preset_id()) === true) {
                         foreach ($fields as $field) {
                             // delete value
                             $field->delete_value();
                         }
                     }
                     // set preset to 0
                     $calendar->update(array('preset_id' => 0));
                     // smarty
                     $sConfirmation->assign('message', parent::lang('class.AnnouncementView#delete#message#done'));
                     $sConfirmation->assign('form', '');
                     // write entry
                     try {
                         $calendar->write_db('update');
                     } catch (Exception $e) {
                         $GLOBALS['Error']->handle_error($e);
                         $output = $GLOBALS['Error']->to_html($e);
                     }
                 }
                 // smarty return
                 return $sConfirmation->fetch('smarty.confirmation.tpl');
             } else {
                 // error
                 $errno = $GLOBALS['Error']->error_raised('WrongParams', 'entry:cid_or_pid', 'cid_or_pid');
                 $GLOBALS['Error']->handle_error($errno);
                 return $GLOBALS['Error']->to_html($errno);
             }
         } else {
             // error
             $errno = $GLOBALS['Error']->error_raised('MissingParams', 'entry:cid_or_pid', 'cid_or_pid');
             $GLOBALS['Error']->handle_error($errno);
             return $GLOBALS['Error']->to_html($errno);
         }
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
コード例 #4
0
 /**
  * movement returns the details of a movement-entry as html
  * 
  * @param int $mid entry-id for the movement
  * @return string html-string with the details of the movement entry
  */
 private function movement($mid)
 {
     // get db-object
     $db = Db::newDb();
     // get movement details
     // prepare sql-statement
     $sql = "SELECT m.inventory_id\n\t\t\t\tFROM inventory_movement AS m\n\t\t\t\tWHERE m.id = {$mid}";
     // execute
     $result = $db->query($sql);
     // fetch result
     list($inventory_id) = $result->fetch_array(MYSQL_NUM);
     // get invetory-object
     $inventory = new Inventory($inventory_id);
     // get preset
     $preset = $inventory->get_preset();
     // get fields
     $fields = $preset->get_fields();
     // check rights
     if (Rights::check_rights($inventory->get_id(), 'inventory')) {
         //smarty-template
         $sM = new JudoIntranetSmarty();
         // prepare sql
         $sql = "SELECT m.id,m.user_id,m.action,m.date_time\n\t\t\t\t\tFROM inventory_movement AS m\n\t\t\t\t\tWHERE m.inventory_id=" . $inventory->get_id() . "\n\t\t\t\t\tORDER BY m.date_time ASC";
         // execute
         $result = $db->query($sql);
         // fetch result
         $i = 0;
         $movements_data = array();
         while (list($m_id, $m_user_id, $m_action, $m_date_time) = $result->fetch_array(MYSQL_NUM)) {
             $movements_data[$i]['id'] = $m_id;
             $movements_data[$i]['user_id'] = $m_user_id;
             $movements_data[$i]['action'] = $m_action;
             $movements_data[$i]['date_time'] = $m_date_time;
             $i++;
         }
         // get actual movement data
         $data = array();
         for ($i = 0; $i < count($movements_data); $i++) {
             // check actual mid and previous
             if ($movements_data[$i]['id'] == $mid) {
                 $data[0]['id'] = $movements_data[$i]['id'];
                 $data[0]['user_id'] = $movements_data[$i]['user_id'];
                 $data[0]['action'] = $movements_data[$i]['action'];
                 $data[0]['date_time'] = $movements_data[$i]['date_time'];
                 // check first
                 if ($i != 0) {
                     $data[1]['id'] = $movements_data[$i - 1]['id'];
                     $data[1]['user_id'] = $movements_data[$i - 2]['user_id'];
                     $data[1]['action'] = $movements_data[$i - 1]['action'];
                 }
             }
         }
         $sM->assign('inventory', parent::lang('class.InventoryView#movement#hx#movement') . $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ')');
         $sM->assign('date', parent::lang('class.InventoryView#movement#hx#at') . date('d.m.Y', strtotime($data[0]['date_time'])));
         $back = array('href' => 'javascript:history.back(1)', 'title' => parent::lang('class.InventoryView#movement#back#title'), 'content' => parent::lang('class.InventoryView#movement#back#name'));
         $sM->assign('back', $back);
         foreach ($data as $movement) {
             // get user
             $user = new User();
             $user->change_user($movement['user_id'], false, 'id');
             // prepare fields
             $fields_out = array();
             foreach ($fields as $field) {
                 // get values
                 $data = array('table' => 'inventory_movement', 'table_id' => $movement['id'], 'field_id' => $field->get_id());
                 $field->read_value($data);
                 $fields_out[] = $field->value_to_html();
             }
             $sM->assign('data', $fields_out);
             $sM->assign('user', parent::lang('class.InventoryView#movement#fields#' . $movement['action']) . ' ' . $user->get_userinfo('name'));
         }
         // return
         return $sM->fetch('smarty.inventory.movement.tpl');
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', $this->get('id'), $mid);
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }