/** * cancel cancels a movement on an inventory object * * @param int $did entry-id for the inventoryitem * @return string html-string with the form */ private function cancel($did) { // check rights if (Rights::check_rights($did, 'inventory')) { // pagecaption $this->tpl->assign('pagecaption', parent::lang('class.InventoryView#page#caption#cancel')); // get inventory-object $inventory = new Inventory($did); // get preset $preset = $inventory->get_preset(); // get fields $fields = $preset->get_fields(); // check owned if ($inventory->get_owned() == 'givento') { // smarty-template $sC = new JudoIntranetSmarty(); // prepare return $return = ''; $form = new HTML_QuickForm2('confirm', 'post', array('name' => 'confirm', 'action' => 'inventory.php?id=cancel&did=' . $did)); // add button $form->addElement('submit', 'yes', array('value' => parent::lang('class.InventoryView#cancel#form#yes'))); // smarty-link $link = array('params' => '', 'href' => 'inventory.php?id=my', 'title' => parent::lang('class.InventoryView#cancel#title#cancel'), 'content' => parent::lang('class.InventoryView#cancel#form#cancel')); $sC->assign('link', $link); $sC->assign('spanparams', 'id="cancel"'); $sC->assign('message', parent::lang('class.InventoryView#cancel#message#confirm')); $sC->assign('form', $form); // validate if ($form->validate()) { // smarty $sC->assign('message', parent::lang('class.InventoryView#cancel#message#done')); $sC->assign('form', ''); // movement to db $insert_id = $this->movement_to_db('taken', $inventory->get_id()); // get values of last movement and values to db $last_values = $inventory->movement_last_values(); $this->values_to_db($insert_id, $fields, $last_values); } // return return $sC->fetch('smarty.confirmation.tpl'); } else { // error $errno = $GLOBALS['Error']->error_raised('NotGiven', $this->get('id'), $did); $GLOBALS['Error']->handle_error($errno); return $GLOBALS['Error']->to_html($errno); } } else { // error $errno = $GLOBALS['Error']->error_raised('NotAuthorized', $this->get('id'), $did); $GLOBALS['Error']->handle_error($errno); return $GLOBALS['Error']->to_html($errno); } }