当前位置: 首页>>代码示例>>PHP>>正文


PHP Inventory::movement_last_accessories方法代码示例

本文整理汇总了PHP中Inventory::movement_last_accessories方法的典型用法代码示例。如果您正苦于以下问题:PHP Inventory::movement_last_accessories方法的具体用法?PHP Inventory::movement_last_accessories怎么用?PHP Inventory::movement_last_accessories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Inventory的用法示例。


在下文中一共展示了Inventory::movement_last_accessories方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: take

 /**
  * take creates the form to take an inventoryitem from somebody else
  * 
  * @param int $did entry-id for the inventoryitem
  * @return string html-string with the form
  */
 private function take($did)
 {
     // check rights
     if (Rights::check_rights($did, 'inventory')) {
         // pagecaption
         $this->tpl->assign('pagecaption', parent::lang('class.InventoryView#page#caption#take'));
         // get db-object
         $db = Db::newDb();
         // get inventory-object
         $inventory = new Inventory($did);
         // check owned
         if ($inventory->get_owned() == 'given') {
             // smarty-template
             $sT = new JudoIntranetSmarty();
             // prepare return
             $return = '';
             // get preset
             $preset = $inventory->get_preset();
             // get fields
             $fields = $preset->get_fields();
             // add headline
             $sT->assign('caption', parent::lang('class.InventoryView#take#page#headline') . ': ' . $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ')');
             // add take from
             $movements = Inventory::movement_last_row($db, $inventory->get_id(), 'user_id', 2);
             $user = new User();
             $user->change_user($movements[1], false, 'id');
             $sT->assign('takefrom', parent::lang('class.InventoryView#take#page#TakeFrom') . ': ' . $user->get_userinfo('name'));
             // add accessory info
             $sT->assign('accessoryinfo', parent::lang('class.InventoryView#take#page#accessory.required'));
             // formular
             $form = new HTML_QuickForm2('inventory_take', 'post', array('name' => 'inventory_take', 'action' => 'inventory.php?id=take&did=' . $this->get('did')));
             // renderer
             $renderer = HTML_QuickForm2_Renderer::factory('default');
             $renderer->setOption('required_note', parent::lang('class.InventoryView#entry#form#requiredNote'));
             // generate field-quickform and add to form
             foreach ($fields as $field) {
                 // check if given
                 if ($inventory->movement_last_accessories($field) === true || $field->get_type() == 'text') {
                     // generate quickform
                     $field->read_quickform();
                 } else {
                     // generate quickform
                     $field->read_quickform(array('disabled' => 'disabled'));
                 }
                 // add to form
                 $form->appendChild($field->get_quickform());
             }
             // submit-button
             $form->addSubmit('submit', array('value' => parent::lang('class.InventoryView#take#form#submitButton')));
             // validate
             if ($form->validate()) {
                 // values
                 $values = $form->getValue();
                 // write to db
                 $insert_id = $this->movement_to_db('taken', $inventory->get_id(), $_SESSION['user']->userid());
                 // accessory to db
                 $this->values_to_db($insert_id, $fields, $values);
                 // headline
                 $sT->assign('action', $inventory->get_name() . ' (' . $inventory->get_inventory_no() . ') ' . parent::lang('class.InventoryView#take#page#headline.taken'));
                 // accessory
                 $sT->assign('accessoryaction', parent::lang('class.InventoryView#take#page#accessory.taken'));
                 // walk through fields
                 $data = array();
                 foreach ($fields as $field) {
                     // check value
                     if (isset($values['inventory-' . $field->get_id()])) {
                         $field_value = $values['inventory-' . $field->get_id()];
                     } else {
                         $field_value = 0;
                     }
                     // return field and value as HTML
                     $field->value($field_value);
                     $data[] = $field->value_to_html();
                 }
                 $sT->assign('form', '');
                 $sT->assign('data', $data);
             } else {
                 $sT->assign('form', $form->render($renderer));
             }
             // return
             return $sT->fetch('smarty.inventory.takegive.tpl');
         } else {
             // error
             $errno = $GLOBALS['Error']->error_raised('NotGivenTo', $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);
     }
 }
开发者ID:BackupTheBerlios,项目名称:judointranet,代码行数:100,代码来源:class.InventoryView.php


注:本文中的Inventory::movement_last_accessories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。